Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获得子类属性而不是super和sub_C#_.net_Reflection - Fatal编程技术网

C# 如何获得子类属性而不是super和sub

C# 如何获得子类属性而不是super和sub,c#,.net,reflection,C#,.net,Reflection,结果:ParentProperty1ParentProperty2ChildProperty1 我需要:ChildProperty1 当我调用GetProperties()时,它给了我当前所有的类属性和基类,但我只需要当前的类属性 请提供任何帮助…用于忽略继承的成员: public class ReflectionBase { public String ParentProperty1 { get; set; } public String ParentP

结果:
ParentProperty1
ParentProperty2
ChildProperty1
我需要:
ChildProperty1

当我调用GetProperties()时,它给了我当前所有的类属性和基类,但我只需要当前的类属性

请提供任何帮助…

用于忽略继承的成员:

public class ReflectionBase
    {
        public String ParentProperty1 { get; set; }
        public String ParentProperty2 { get; set; }        
    }

    public class Reflection : ReflectionBase
    {
        public String ChildProperty1 { get; set; }

        public Reflection()
        {
            var property = this.GetType().GetProperties();
        }    
    }
var properties = this.GetType().GetProperties(
    BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);