Share via


CLSCompliantAttribute Class

Indicates whether a particular program element is compliant with the Common Language Specification (CLS).

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

[AttributeUsageAttribute]
[SerializableAttribute]
public sealed class CLSCompliantAttribute : Attribute

Remarks

This class cannot be inherited.

You can apply the CLSCompliantAttribute attribute to the following types of program elements: assemblies, classes, constructors, delegates, enums, events, fields, interfaces, methods, modules, parameters, properties, return values, and structs. Note, however, that the concept of CLS compliance is meaningful only for assemblies, modules, types, and members of types, and not for parts of a member signature. Consequently, CLSCompliantAttribute is ignored when it is applied to parameters or return values.

If no CLSCompliantAttribute attribute is applied to a particular assembly, type, or member of a type, the following are true (respectively) by default:

  • The assembly is not CLS-compliant.
  • The type is CLS-compliant only if its enclosing type or assembly is CLS-compliant.
  • The member of a type is CLS-compliant only if the type is CLS-compliant.

If an assembly is marked as CLS-compliant, you must mark any publicly exposed type in the assembly that is not CLS-compliant with CLSCompliantAttribute, using a false argument. Similarly, if a class is marked as CLS-compliant, you must individually mark all members of that class that are not CLS-compliant. For all noncompliant members, you must provide corresponding CLS-compliant alternatives.

Attributes that are applied to assemblies or modules must occur after the C# "using" statements and before the actual code.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, and 4.1.

See Also

Reference

CLSCompliantAttribute Members
System Namespace