Let’s have a quick review what kind of built-in data types in C#.
In Brief:
string -> alphanumeric (defaults to “”)
int -> 2 billion to -2 billion (defaults to 0)
double -> fractional value (defaults to 0.0)
bool -> true or false (defaults to false)
The following explanation has been taken from microsoft.com in order to understand you better;
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();
Note that the type must be specified both for simple, built-in types such as an int, and for complex or custom types such as XmlDocument.
C# includes support for the following built-in data types:
Data Type | Range |
---|---|
byte | 0 .. 255 |
sbyte | -128 .. 127 |
short | -32,768 .. 32,767 |
ushort | 0 .. 65,535 |
int | -2,147,483,648 .. 2,147,483,647 |
uint | 0 .. 4,294,967,295 |
long | -9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807 |
ulong | 0 .. 18,446,744,073,709,551,615 |
float | -3.402823e38 .. 3.402823e38 |
double | -1.79769313486232e308 .. 1.79769313486232e308 |
decimal | -79228162514264337593543950335 .. 79228162514264337593543950335 |
char | A Unicode character. |
string | A string of Unicode characters. |
bool | True or False. |
object | An object. |
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.