Skip to main content
 首页 » 编程设计

c#之类名周围的括号在 C# 类中意味着什么

2024年02月13日14mate10pro

作为 .NET 和 C# 领域的初学者,当我在 .CS 文件的开头看到以下语法时,我不知道这意味着什么?我对名称周围括号的含义感到困惑?预先感谢您的帮助。

   [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "55.555.5.555")] 
   [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "5.5.34444.55")] 
   [System.SerializableAttribute()] 
   [System.Diagnostics.DebuggerStepThroughAttribute()] 
   [System.ComponentModel.DesignerCategoryAttribute("code")] 

请您参考如下方法:

它们被称为 Attributes并为您的类(class)提供元数据。

例如,SerializableAttribute 让一些类知道您的对象可以写入磁盘或通过网络连接发送到另一个程序。