Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
"name" é ambíguo entre "name" e "nameAttribute"; use "@name" ou "nameAttribute".
O compilador encontrou uma especificação de atributo ambíguo.
Para sua conveniência, o compilador do C# permite que você especifique ExampleAttribute simplesmente como [Example]. No entanto, surgirá uma ambiguidade se uma classe de atributo com nome Example existir juntamente com o ExampleAttribute, porque o compilador não poderá determinar se [Example] refere-se ao atributo Example ou o atributo ExampleAttribute. Para deixar mais claro, use [@Example] para o atributo Example e [ExampleAttribute] para ExampleAttribute.
O exemplo a seguir gera o erro 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() {
}
}