using System; using System.Collections.Generic; using System.Text;namespace WindowsApplication1 { public class MyClass { public MyClass() { } private string _name; public String Name { get { return _name; } set { _name = value; } } } } private void button3_Click(object sender, EventArgs e) { MyClass my = new MyClass(); Type T = my.GetType(); PropertyInfo[] ps = T.GetProperties(); for (int i = 0; i < ps.Length; i++) { listBox1.Items.Add(ps[i].Name); } }
object[] obj11 = typeof(类名).GetCustomAttributes(true);
PropertyInfo[] properties = typeof(yourclass).GetProperties();
using System;
using System.Collections.Generic;
using System.Text;namespace WindowsApplication1
{
public class MyClass
{
public MyClass()
{
} private string _name;
public String Name
{
get { return _name; }
set { _name = value; }
}
}
}
private void button3_Click(object sender, EventArgs e)
{
MyClass my = new MyClass();
Type T = my.GetType();
PropertyInfo[] ps = T.GetProperties();
for (int i = 0; i < ps.Length; i++)
{
listBox1.Items.Add(ps[i].Name);
}
}