Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net .NET3.5反射帮助_Vb.net_Reflection - Fatal编程技术网

Vb.net .NET3.5反射帮助

Vb.net .NET3.5反射帮助,vb.net,reflection,Vb.net,Reflection,伙计们 在我的业务层,我有 Dim object as New ExampleObject 其中ExampleObject继承BaseExampleObject 我想知道如何通过对BaseExampleObject的反射来访问ExampleObject属性 比如: MyBase.GetType.GetProperty("PropertyName").GetValue(mybase.gettype, Nothing) 当然,这是行不通的,因为这不是一个对象的实例,如果我实例化了一个新对象,我将

伙计们

在我的业务层,我有

Dim object as New ExampleObject
其中ExampleObject继承BaseExampleObject

我想知道如何通过对BaseExampleObject的反射来访问ExampleObject属性

比如:

MyBase.GetType.GetProperty("PropertyName").GetValue(mybase.gettype, Nothing)
当然,这是行不通的,因为这不是一个对象的实例,如果我实例化了一个新对象,我将丢失来自业务层的引用

有人得到提示吗


谢谢

将BaseExampleObject转换为ExampleObject:

BaseExampleObject b;
b = new ExampleObject();
((ExampleObject)b).Something();

BaseExampleObject是一个mustinherit类,我为许多类提供了一些常用方法,这就是为什么我需要通过反射访问它们的属性,而且,强制转换一个已经继承的对象有点像WOP。