🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Compiler Error CS1614 “name”不明确的;在“attribute1”和“attribute2”之间。请使用" @attribute”或“attributeAttribute” 编译器遇到了意义不明确的特性指定。 为简便起见,C# 编译器允许将 **ExampleAttribute** 指定为 [Example]。不过,如果名为 **Example** 的特性类与 **ExampleAttribute** 同时存在,则会引起多义性,因为编译器无法判断 [Example] 是指 **Example** 特性还是指 **ExampleAttribute** 特性。要解决此问题,请对 **Example** 特性使用 [@Example],对 **ExampleAttribute** 使用 [ExampleAttribute]。 下面的示例生成 CS1614: ``` // CS1614.cs using System; // Both of the following classes are valid attributes with valid // names (MySpecial and MySpecialAttribute). However, because the lookup // rules for attributes involves auto-appending the 'Attribute' suffix // to the identifier, these two attributes become ambiguous; that is, // if you specify MySpecial, the compiler can't tell if you want // MySpecial or MySpecialAttribute. public class MySpecial : Attribute { public MySpecial() {} } public class MySpecialAttribute : Attribute { public MySpecialAttribute() {} } class MakeAWarning { [MySpecial()] // CS1614 // Ambiguous: MySpecial or MySpecialAttribute? public static void Main() { } [@MySpecial()] // This isn't ambiguous, it binds to the first attribute above. public static void NoWarning() { } [MySpecialAttribute()] // This isn't ambiguous, it binds to the second attribute above. public static void NoWarning2() { } [@MySpecialAttribute()] // This is also legal. public static void NoWarning3() { } } ```