Reputation: 25834
[DebuggerDisplayAttribute("{_name}")]
vs
[DebuggerDisplay("{_name}")]
Is there a difference? Is one an alias of the other? Does VS automatically check for a class named fooAttribute when using an attribute named foo?
Upvotes: 3
Views: 447
Reputation: 21684
There is no difference. The standard convention in naming the class is to append the word Attribute, as in:
public class AlertAttribute : Attribute {}
When using the attribute, the standard convention is to eliminate the word, as in:
[Alert()]
From Attributes (C# and Visual Basic) at http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx
By convention, all attribute names end with the word "Attribute" to distinguish them from other items in the .NET Framework. However, you do not need to specify the attribute suffix when using attributes in code. For example, [DllImport] is equivalent to [DllImportAttribute], but DllImportAttribute is the attribute's actual name in the .NET Framework.
Upvotes: 5
Reputation: 311315
They're the same. You tend to see the fully qualified name in generated code, especially that output via CodeDom.
You can use either one. The compiler generates the same thing in the end.
Upvotes: 5
Reputation: 27757
They are the same, the C# compiler will be able to resolve the type whether you write Attribute at the end or not.
Upvotes: 9