According to this stackoverflow answer you can't apply a custom attribute to an anonymous method.
What is AttributeTargets.Delegate
then for?
Is it for another .NET language?
Anonymous methods are not delegates. Delegates are declarations of method types.
For example:
[AttributeUsage(AttributeTargets.Delegate)]
public class DelegateTargetAttribute : Attribute
{ }
public class Example
{
[DelegateTarget]
public delegate int Foo (string bar);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.