refer: class Program { static void Main(string[] args) { Test test = new Test(); test.CardNo = "877878"; object obj = test; Type type = obj.GetType(); Console.WriteLine(type.GetProperty("CardNo").GetValue(obj, null));//获得obj对象的CardNo属性值 877878 } } public class Test { public string CardNo { get; set; } }
class Program
{
static void Main(string[] args)
{
Test test = new Test();
test.CardNo = "877878"; object obj = test;
Type type = obj.GetType();
Console.WriteLine(type.GetProperty("CardNo").GetValue(obj, null));//获得obj对象的CardNo属性值 877878
}
} public class Test
{
public string CardNo { get; set; }
}