編譯器錯誤 CS0643
更新:2007 年 11 月
錯誤訊息
具名屬性引數 'arg' 重複指定
arg 參數在使用者定義的屬性 (Attribute) 上被指定兩次。如需詳細資訊,請參閱屬性 (C# 程式設計手冊)。
範例
下列範例會產生 CS0643:
// CS0643.cs
using System;
using System.Runtime.InteropServices;
[AttributeUsage(AttributeTargets.Class)]
public class MyAttribute : Attribute
{
public MyAttribute()
{
}
public int x;
}
[MyAttribute(x = 5, x = 6)] // CS0643, error setting x twice
// try the following line instead
// [MyAttribute(x = 5)]
class MyClass
{
}
public class MainClass
{
public static void Main ()
{
}
}