Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.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# 如何获取不带';在运行时不包含属性_C#_Reflection_Attributes - Fatal编程技术网

C# 如何获取不带';在运行时不包含属性

C# 如何获取不带';在运行时不包含属性,c#,reflection,attributes,C#,Reflection,Attributes,因此,我有一个属性,我是这样创建的: public class IgnoreFilter : Attribute { } 我有一个我用过的类,也是这样: public class Customer { private string name; public string Name { get { return name; } set { name = value; Rais

因此,我有一个
属性
,我是这样创建的:

public class IgnoreFilter : Attribute
{
}
我有一个我用过的类,也是这样:

public class Customer
{

    private string name;
    public string Name
    {
        get { return name; }
        set
        {
            name = value;
            RaisePropertyChanged();
        }
    }

    private string address;
    [IgnoreFilter]
    public string Address
    {
        get { return address; }
        set
        {
            address = value;
            RaisePropertyChanged();
        }
    }
我现在正试图在运行时从我的
Customer
类中获取所有不包含
IgnoreFilter
属性的属性。到目前为止我已经

customer.GetType().GetRuntimeProperties().Where(p => !p.CustomAttributes.Contains(typeof(IgnoreFilter)));
但是最后一行没有编译。我想我的思路是对的,但我可能遗漏了什么


有人可以帮助从不包含自定义属性的类中获取属性吗?

来自我最后使用的注释:

customer.GetType().GetRuntimeProperties().Where(p =>  p.CustomAttributes.FirstOrDefault(x => x.AttributeType == typeof(IgnoreFilter)) == null);

包含的
错误。使用
of type().Any()
或只使用
Any(o=>o.GetType()==typeof(IgnoreFilter))
@Sinatr谢谢,工作非常完美
FirstOrDefault()==null
!Any()