Data Types (Cont.)


Object Types
The object type (System.Object class) is the ultimate base class for all data types. The object types can be assigned values of any other types. However, before assigning values, it needs type conversion. When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing:
   object obj;     obj = 100;     // this is boxing
Dynamic Types
You can store any type of value in the dynamic data type variable. Dynamic types are similar to object types except that type checking for object type variables takes place at compile time, whereas that for the dynamic type variables takes place at run time. Syntax for declaring a dynamic type is dynamic <variable_name> = value;; e.g.,
     dynamic d = 20;
String Types
The string type (System.String class) allows you to assign any string values to a variable. The value for a string type can be assigned using string literals in two forms: quoted and @quoted. For example,
     String str = "Tutorials Point";
A @quoted string literal looks as follows −
     @"Tutorials Point";
Pointer Types
Pointer type variables store the memory address of another type. Pointers in C# have the same capabilities as the pointers in C or C++. Syntax for declaring a pointer type is type* identifier;. For example,
     char* cptr;     int* iptr;