Built-in Data Types
C# is a strongly-typed language. Before a value can be stored in a variable, the type of the variable must be specified, as in the following examples:
int a = 1; string s = "Hello"; XmlDocument tempDocument = new XmlDocument();
C# includes support for the following built-in data types:
0 .. 255
-128 .. 127
-32,768 .. 32,767
0 .. 65,535
-2,147,483,648 .. 2,147,483,647
0 .. 4,294,967,295
-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807
0 .. 18,446,744,073,709,551,615
-3.402823e38 .. 3.402823e38
-1.79769313486232e308 .. 1.79769313486232e308
-79228162514264337593543950335 .. 79228162514264337593543950335
A Unicode character.
A string of Unicode characters.
True or False.
These data type names are aliases for predefined types in the System namespace. They are listed in the section Built-In Types Table (C# Reference). All these types, with the exception of object and string, are value types. For more information, see Value and Reference Types.
Built-in data types are used within a C# program in several ways.
As return values and parameters:
Converting between data types can be done implicitly, in which the conversion is done automatically by the compiler, or explicitly using a cast, in which the programmer forces the conversion, and assumes the risk of losing information.