嗨,我正在使用C#在类库中工作,我有一些带有一些属性的类.
我只想知道我是否可以添加一些内容来从getType().GetProperties()中排除一些属性.
我想要的一个例子:
课堂考试
{
Run Code Online (Sandbox Code Playgroud)class Test { public string one { get; set; } public string two {get ; set;} }}
如果我这样做:
static void Main(string [] args)
{
Run Code Online (Sandbox Code Playgroud)static void Main(string[] args) { Test t = new Test(); Type ty = t.GetType(); PropertyInfo[] pinfo = ty.GetProperties(); foreach (PropertyInfo p in pinfo) { Console.WriteLine(p.Name); } }}
我希望输出是这样的:
一
或者只是其中一个属性.
有可能做那样的事吗?我不知道C#中是否有某种修饰符或注释,这使我能够按照自己的意愿行事.
谢谢.