我试图从字符串引用公共属性。这怎么能在vb.net中完成? 我有存储在strucParam(i).TxtPropertyName中的“FirstName”的文本值。使用字符串动态引用对象属性
这是目前我在做什么:
Dim tmpValue As String
Dim ucAppName As UserControl_appName = CType(Parent.FindControl(strucParam(i).ParentFindControl), UserControl_appName)
tmpValue = ucAppName.FirstName.Text
我怎样才能在strucParam(我).TxtPropertyName使用该值,这样我可以从我的代码中删除“.FirstName”?谢谢!
我无法使用null。我不得不用Nothing来代替它。运行以下代码时,出现“对象与目标类型不匹配”错误。 FirstName属性实际上是一个文本框。所以我不需要以某种方式在代码中引用.Text? tmpFirstName = ucAppName.GetType()。GetProperty(strucParam(i).PropertyName).GetValue(objAppNav,Nothing) – crjunk 2011-01-21 18:12:32