[DebuggerDisplayAttribute("{_name}")]
Run Code Online (Sandbox Code Playgroud)
VS
[DebuggerDisplay("{_name}")]
Run Code Online (Sandbox Code Playgroud)
有区别吗?一个是别人的别名吗?当使用名为foo的属性时,VS是否自动检查名为fooAttribute的类?
没有区别.命名类的标准约定是附加单词Attribute,如下所示:
public class AlertAttribute : Attribute {}
Run Code Online (Sandbox Code Playgroud)
使用属性时,标准约定是消除单词,如:
[Alert()]
Run Code Online (Sandbox Code Playgroud)
来自属性(C#和Visual Basic),网址为http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx
按照惯例,所有属性名称都以单词"Attribute"结尾,以区别于.NET Framework中的其他项.但是,在代码中使用属性时,不需要指定属性后缀.例如,[DllImport]等同于[DllImportAttribute],但DllImportAttribute是.NET Framework中属性的实际名称.