using System;
using System.Reflection;
namespace 反射
{
class Myclass
{
private int myProperty;
public int MyProperty
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
try
{
Type myType = typeof(Myclass);
PropertyInfo myProinfo = myType.GetProperty("MyProperty");
Console.WriteLine(myType.Name);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
using System.Reflection;
namespace 反射
{
class Myclass
{
private int myProperty;
public int MyProperty
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
try
{
Type myType = typeof(Myclass);
PropertyInfo myProinfo = myType.GetProperty("MyProperty");
Console.WriteLine(myType.Name);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}