C# – Data Types

There are two kinds of data types in C#.

  • Value Type ( Implicit data types , structs and enumeration)
  • Reference Types ( objects, delegates )

Value types are passed to methods are passing an exact copy while Reference types are passed to method by passing only their reference ( handle) . Implicit data types are defined in the language core by the language vendor, while Explicit data types that are made by using or composing implicit data types.

Integral Types

C# type .Net type Size in bytes Description
byte Byte 1 May contain integers from 0-255
byte SBte 1 Singed byte from -128 to 127
short Int16 2 Ranges from -32,768 to 32,767
ushort UInt16 2 Unsigned , ranges from 0 to 65,535
int(default) Int32 4 Ranges from -2,147,483,648 to 2,147,483,647
uint UInt32 4 Unsigned, ranges from 0 to 4,294,967,295
long Int64 8 Ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong UInt64 8 Unsigned, ranges from 0 to 18,446,744,073,709,551,615

Floating point Types

Float Single 4 Ranges from
double
(default)
Double 8  

Other Types

bool Boolean 1 Contains either true or false
char Char 2 Contains any single Unicode character enclosed in single quotation mark such as ‘c’
decimal Decimal 12 Ranges from 1.0

Leave a Reply

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