就像Type.GetProperties()的效果,只不过Type.GetProperties()只对系统定义的类有用,可是我想获得自定义的类的属性名称怎么办
解决方案 »
- 正则表达式匹配问题
- context.user.tolist()怎么作参数
- 能不能实现类似QQ的richtextbox
- 紧急求帮助,一个CALLBACK的回调系统异常
- 关于数据备份问题,在线等
- grideview 已经显示表了,为什么this.GridView1.Columns.Count的值是0?
- 为什么datagrid中有些字段 它显示的是(空)阿
- 服务器返回请求的的问题,.Net请求返回的内部机制.很难!
- 一个简单问题。。调试c#中出现得问题。。
- C#新手提问关于连接数据库的问题?请大家帮帮忙!在线等……
- 请问C#如何实现C++中的函数指针
- DataView or DataTable 中 实现单个字符 '_'的模糊查询
------------
谁告诉你的?哪本书上讲过...自定义的Type就不是Type吗...
namespace ConsoleApplication1
{
class MyClass
{
public string name;
public int age;
}
class Program
{
static void Main(string[] args)
{
PropertyInfo[] propertys = System.Type.GetType("ConsoleApplication1.MyClass").GetProperties();
foreach(PropertyInfo n in propertys)
{
Console.WriteLine(n.Name);
}
Console.Read();
}
}
}如果是这样就没问题:
class Program
{
static void Main(string[] args)
{
PropertyInfo[] propertys = System.Type.GetType("System.Collections.ArrayList").GetProperties();
foreach(PropertyInfo n in propertys)
{
Console.WriteLine(n.Name);
}
Console.Read();
}
}
-----------
你那个name和age是属性啊...小写,别误会了...