如何获取属性名称?
class Program
{
public string age { get; set; }
static void Main()
{
Program temp = new Program();
temp.age = "123";
Type t = temp.GetType();
Console.WriteLine(t.Name);//输出Program
//怎么得到“Program.Name”,通过temp.Name
}
}
------解决方案-------------------- class Program
{
public string age { get; set; }
static void Main()
{
Program temp = new Program();
temp.age = "123";
//Type t = temp.GetType();
Console.WriteLine(temp.Name);//输出123
}
}
------解决方案--------------------反射应该可以吧、
------解决方案--------------------------解决方案--------------------
public string age { get; set; }
public string id { get; set; }
static void Main(string[] args)
{
Program p = new Program();