1.概要
返回为当前 System.Type 的所有公共属性。
2.代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace 属性实验
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("属性实验");
A a = new A();
Type type = a.GetType();
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos) {
Console.WriteLine(propertyInfo.Name);
}
Console.ReadKey();
}
}
class A {
public int Ma{set;get;}
public int Mb { set; get; }
public int mc;
private int Md { set; get; }
protected int Me { set; get; }
}
}
3.结果
属性实验
Ma
Mb
4.分析