Ensuring CLS Compliance
As you will see over the course of this book, C# does define a number of programming constructs
that are not CLS-compliant. The good news, however, is that you can instruct the C# compiler to
check your code for CLS compliance using a single .NET attribute:
// Tell the C# compiler to check for CLS compliance.
[assembly: System.CLSCompliant(true)]
Chapter 16 dives into the details of attribute-based programming. Until then, simply under-
stand that the [CLSCompliant] attribute will instruct the C# compiler to check each and every line of
code against the rules of the CLS. If any CLS violations are discovered, you receive a compiler error
and a description of the offending code.
Do'stlaringiz bilan baham: |