111,089
社区成员




class Program
{
static void Main(string[] args)
{
a a1111 = new a();
a1111.a1 = "hello.";
Type type = a1111.GetType();
string name = "a1";//输出属性的名称
PropertyInfo pi = type.GetProperties().FirstOrDefault(x => x.Name == name);
Console.WriteLine(pi.GetValue(a1111, null));//输出:hello.
}
}
public class a
{
public string a1 { get; set; }
}