The structure below shows the various basic types of C# and the types they map to in the .Net framework.

C# Short Name .Net Class Declaration Description
bool Boolean bool isValid = true;

8 bit true or false

sbyte SByte sbyte b = -1 signed 8 bit integer
byte Byte byte b = 1; 8 bit unsigned integer
char Char char = 'a' 16 bit single Unicode character
short Int16 short s = 123; 16bit signed integer
ushort UInt16 ushort s = 15; 16bit unsigned integer
int Int32 int i = -1000000; 32bit signed integer
uint UInt32 uint i = 50000; 32bit unsigned integer
long Int64 long = 2000; 64 bit signed integer
ulong UInt64 ulong = 2000; 64 bit unsigned integer
float Single float f = 1.04f; 4 byte single precision floating point
double Double double d = 1.0E-13 8 byte double precision floating point
decimal Decimal   16 byte precise fractional or integral type that can represent decimal numbers with 29 significant digits
string String string s = "abcd"; A sequence of unicode characters

Binary Values

You can't specify a binary value in C# – specify in hexadecimal instead.

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *