英語で読む

次の方法で共有


コンパイラ エラー CS0181

属性コンストラクター パラメーターに、有効な属性パラメーター型ではない型があります

次の例では CS0181 が生成されます。

C#
// CS0181.cs (12,6)

using System;
using System.Runtime.InteropServices;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
unsafe class Attr : Attribute
{
    public Attr(delegate*<void> d) {}
}
unsafe class C
{
    [UnmanagedCallersOnly]
    [Attr(&M1)]
    static void M1()
    {
    }
}

CLR では現在のところ、ジェネリック属性パラメーター型が許可されません。そのため、C# では、ジェネリック属性パラメーター型が許可されません。