This is a C# console app I created in Visual Studio to demonstrate some common data types.
using System; namespace TypeConversionApplication { class StringConversion { static void Main(string[] args) { int i = 75; float f = 53.005f; double d = 2345.7652; bool b = true; Console.WriteLine("int: " + i.ToString()); Console.WriteLine("float: " + f.ToString()); Console.WriteLine("double: " + d.ToString()); Console.WriteLine("boolean: " + b.ToString()); Console.ReadKey(); } } }
Data Types
int : An integer(eg, 3).
Can be a whole number between -2147483648 and 2147483647
float : A fractional(floating point) number(eg, 3.25907).
Can be a number between roughly 1.5 x 10^45 to 3.4 10^38, in floating point format.
String : A sequence of characters(eg, “Hello User 6555”)
(no specified maximum length)
boolean : A true/false value.
Can only contain either the value true or false.
Others
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. |
Reference