Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将一个或多个属性应用于项目中的所有类?_C#_Attributes_Class Attributes_Cls Compliant_Class Attribute - Fatal编程技术网

C# 如何将一个或多个属性应用于项目中的所有类?

C# 如何将一个或多个属性应用于项目中的所有类?,c#,attributes,class-attributes,cls-compliant,class-attribute,C#,Attributes,Class Attributes,Cls Compliant,Class Attribute,如何将属性应用于特定项目中的所有类?! 将CLSCompliant属性应用于一个类就足够了,还是必须应用于所有类 感谢您的回答。项目是程序集,因此您可以使用。项目是程序集,因此您可以使用。这是属性的声明: [SerializableAttribute] [ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)] public

如何将属性应用于特定项目中的所有类?! 将CLSCompliant属性应用于一个类就足够了,还是必须应用于所有类


感谢您的回答。

项目是程序集,因此您可以使用。

项目是程序集,因此您可以使用。

这是属性的声明:

[SerializableAttribute]
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public sealed class CLSCompliantAttribute : Attribute
请注意[AttributeUsage]。对于AttributeTargets.All,它表示该属性可以应用于任何对象。其中包括大会:

[assembly:CLSCompliant(true)]

这是属性的声明:

[SerializableAttribute]
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public sealed class CLSCompliantAttribute : Attribute
请注意[AttributeUsage]。对于AttributeTargets.All,它表示该属性可以应用于任何对象。其中包括大会:

[assembly:CLSCompliant(true)]