Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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# AttributeTargets.Delegate的用法_C#_Custom Attributes - Fatal编程技术网

C# AttributeTargets.Delegate的用法

C# AttributeTargets.Delegate的用法,c#,custom-attributes,C#,Custom Attributes,根据stackoverflow answer,您不能将自定义属性应用于匿名方法 那是干什么用的 它是用于另一种.NET语言吗?匿名方法不是委托。是方法类型的声明 例如: [AttributeUsage(AttributeTargets.Delegate)] public class DelegateTargetAttribute : Attribute { } public class Example { [DelegateTarget] public delegate int

根据stackoverflow answer,您不能将自定义属性应用于匿名方法

那是干什么用的


它是用于另一种.NET语言吗?

匿名方法不是委托。是方法类型的声明

例如:

[AttributeUsage(AttributeTargets.Delegate)]
public class DelegateTargetAttribute : Attribute
{ }

public class Example
{
    [DelegateTarget]
    public delegate int Foo (string bar);
}