How do you put a Func in a C# attribute (annotation)?

前端 未结 2 822
失恋的感觉
失恋的感觉 2021-01-03 20:55

I have a C# annotation which is :

[AttributeUsage(AttributeTargets.Method)]
public class OperationInfo : System.Attribute {
    public enum VisibilityType {
         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 21:19

    From the C# spec:

    17.1.3 Attribute parameter types

    The types of positional and named parameters for an attribute class are limited to the attribute parameter types, which are:

    · One of the following types: bool, byte, char, double, float, int, long, sbyte, short, string, uint, ulong, ushort.

    · The type object.

    · The type System.Type.

    · An enum type, provided it has public accessibility and the types in which it is nested (if any) also have public accessibility (§17.2).

    · Single-dimensional arrays of the above types.

提交回复
热议问题