相关疑难解决方法(0)

C#VS 2005:如何在运行时获取类的公共成员列表?

我正在尝试在运行时获取类memeber变量列表.我知道这可能是使用typeof和反射.但找不到一个例子.请有人为我照亮.

这是伪代码示例:

Class Test01
{ 
 public string str01;
 public string str02;
 public int myint01;
}
Run Code Online (Sandbox Code Playgroud)

我想要这样的东西(伪代码):

Test01 tt = new Test01();
foreach(variable v in tt.PublicVariableList)
{
   debug.print v.name;
   debug.print v.type;
}
Run Code Online (Sandbox Code Playgroud)

请帮我弄清楚如何在C#VS2005中做到这一点

非常感谢

c# reflection typeof

2
推荐指数
1
解决办法
3430
查看次数

标签 统计

c# ×1

reflection ×1

typeof ×1