The .NET Framework Class Library

The .NET Framework class library contains a number of base data types for use in your application. However, the .NET Framework class actually supports many base types that are not compliant with the Common Language Specification, or CLS. It is important to know what types are and are not available to the CLS, but first it is useful to understand the CLS.

What Is the Common Language Specification?

The Common Language Specification (CLS) is a subset of the language features directly supported by the Common Language Runtime. The runtime lays out a set of rules to guarantee cross-language interoperability. By defining types and rules that all CLS-compliant code must use, you are guaranteed that a class written in C# can be inherited by any other .NET language. You can rest assured that the data types of properties and parameters are compatible across languages.

By using only types that are included in the CLS, your component will be accessible to clients written in any other language that supports the CLS. Basically, the CLS specifies a set of rules to which all languages must adhere in order to have full cross-language interoperability under the .NET Framework. Realize that only what is exposed by your component needs to be CLS-compliant. Inside a method, for example, you can use private variables that are not CLS-compliant, but the method can still be CLS-compliant because all the exposed items are part of the CLS.

The CLS specifies not just data types, but also a number of rules. Right now, there are 41 rules that specify the CLS. For example, one rule specifies that the type of an enum must be one of the four CLS integer data types. Most of these rules are transparent to you as a developer because the Visual Studio .NET environment handles them for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.36.247