In .NET world, Type refers to a generic term used to represent Class, Interface, Enumeration , Delight etc. Whenever we are building any solution around .NET we do interact with these types. So lets define CTS aka Common Type System as "CTS defines how various types are declared, used and managed in Common Language Runtime in .NET world"
- CTS helps in cross language interaction
- Provides an Object oriented model
- Defines the rules that languages should follow for language interaction.
- Provides a Base class library that contains primitive data types.
Types can be literally classified as Value Types and Reference Types. Lets define the classification as follows
Value Types:
Value types are data types whose objects are represented by the object's actual value. If an instance of a value type is assigned to a variable, that variable is given a fresh copy of the value.
Reference Types:
Reference types are data types whose objects are represented by a reference (similar to a pointer) to the object's actual value. If a reference type is assigned to a variable, that variable references (points to) the original value. No copy is made.
CTS supports the following categories of types
- Classes : Classes are Reference types. It defines the operation an object can perform and the data that object contains
- Structures : Structures refers to Value types. It derives from System.ValueType. Used extensively in low memory requirements.
- Enumerations : Enumeration are Value types. It derives from System.Enum. It supplies alternate names for the values of an underlying primitive type.
- Interfaces : Interfaces are contracts which contains declarations of method or properties which an implementing class will do the implementation.
- Delegates : Delegates are Reference types which is a functional pointer used in event handlers and call back functions in .NET.
CTS type definitions includes the following
- Any attribute defined on type
- Type accessibility
- Type name
- Types base types
- Any interface defined by the types
- Definition for each type members
Type members defines the behavior and state of a types. The following are type members
- Fields
- Properties
- Methods
- Constructors
- Events
- Nested types
No comments:
Post a Comment