asp.net.ph

CLSCompliantAttribute Class

System Namespace


Indicates whether a program element is compliant with the Common Language Specification ( CLS ). This class cannot be inherited.

CLSCompliantAttribute Class Members

Collapse   Constructors

Visibility Constructor Parameters
public CLSCompliantAttribute ( Boolean isCompliant )

Collapse   Properties

Visibility Name Value Type Accessibility
public IsCompliant Boolean [ Get ]

Remarks

If no CLSCompliantAttribute is applied to a program element, 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 is CLS-compliant only if the type in which the member is CLS-compliant.

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

Attributes that are applied to assemblies or modules must occur after the using clauses and before the code.

For more information about using attributes, see Extending Metadata Using Attributes.

NOTE: The current Microsoft Visual Basic compiler intentionally does not generate a CLS-compliance warning, however, a future release of the compiler will issue that warning.

Example

The following example applies a CLSCompliantAttribute to the entire assembly. using System;

[ assembly:CLSCompliant ( true ) ]

The following declaration generates a CLS-compliance warning because the type UInt32 is not specified in the CLS.

public int SetValue ( UInt32 value );

If the declaration is marked with a CLSCompliantAttribute, no compiler warning or error is generated.

[ CLSCompliant ( false ) ]

public int SetValue ( UInt32 value );

See Also

Attribute Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph