请问asp.net c#里 [ ] 里的内容代表什么呢?谢谢

请问asp.net c#里 [ ] 里的内容代表什么呢?
比如
#region Server Control
[HostingPermission(SecurityAction.Demand, Level = HostingPermissionLevel.Minimal)]
public class Test
{}
#endregion

中[HostingPermission(SecurityAction.Demand, Level = HostingPermissionLevel.Minimal)] 里面代表的是什么意思?谢谢。

这叫 属性。也就是 现在你声明的类Test 具有 HostingPermission 属性。[HostingPermission(SecurityAction.Demand, Level = HostingPermissionLevel.Minimal)] 这里是调用了HostingPermission 属性类的构造函数。可以自定义 属性,只要继承 System.Attribute 类就行了
温馨提示:答案为网友推荐,仅供参考
相似回答