The Role of the Common Language Specification  (CLS)
The Common Language Specification (CLS) is a subset of the CTS.  The CLS defines the minimal features a
language must support to be considered a .NET language.  If a complier abides by the CLS rules, all other .NET
languages can use the resulting binaries in a uniform manner.  By and large, only developers creating a new .NET
language need to engross themselves in the full details of the CLS.  Nevertheless, it is enlightening to examine
some of these rules firsthand.  

CLS rule: All classes ultimately derive from System.Object:   

For the time being, don’t concern yourself with the exact syntax seen below.   We will see the details of System.
Object later in this class.

    ' The top-most class in the .NET world: System.Object
    Public Class Object      
      ' Reference equality by default. Override for value semantics.
      Public Overridable Function Equals(obj As Object) As Boolean
      Public Shared Function Equals(objA As Object, objB As Object) _
         As Boolean

      ' Get hash value for object. Override for efficient Hash table use.
      Public Overridable Function GetHashCode() As Integer
            
      ' RTTI for this object.     
      Public Function GetType() As Type
      
      ' Override to produce state data in string format.                      
      Public Overridable Function ToString() As String
      
      ' Override to cleanup resources (non-deterministic destruction)        
      Protected Overridable Sub Finalize()                      
    End Class

CLS rule: Every class has exactly one base class but may implement multiple interfaces.

Like Java, the CLS does not support multiple inheritance for class types. C++ developers take note.  Like Java,
the CLS allows a class to implement multiple interfaces.  It is possible for an interface to have multiple base
interfaces. In other words, multiple interface inheritance is supported.  CLS rule: Every type in an assembly
must specify its visibility. Although a given language may have unique keywords, the basic visibility settings
are:

  • Public: visible to anyone, anywhere.
  • Private: only visible to members of the defining type.
  • Protected: only visible to members of the defining type or members of derived types.
  • Internal: visible to any type defined within the assembly.  In VB, internal visibility is defined using the
    Friend keyword.

CLS rule: All data points must map to the types defined by the CTS.

The CTS defines a set of core data types, each of which has a corresponding object in the System namespace.  
As far as the type system itself is concerned, a type can be from the set {class, interface, structure,
enumeration, delegate}.  Since the release of .NET 2.0, all types but enumerations may be created generically.
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Common Language Specification (CLS)
Table of Contents
Courseware
Training Resources
Tutorials