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 typeSize in bytesDescription
byte Byte1May contain integers from 0-255
byteSBte1Singed byte from -128 to 127
shortInt162Ranges from -32,768 to 32,767
ushortUInt162Unsigned , ranges from 0 to 65,535
int(default)Int324Ranges from -2,147,483,648 to 2,147,483,647
uintUInt324Unsigned, ranges from 0 to 4,294,967,295
longInt648Ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulongUInt648Unsigned, ranges from 0 to 18,446,744,073,709,551,615

Floating point Types

FloatSingle 4Ranges from

Other Types

boolBoolean1Contains either true or false
charChar2Contains any single Unicode character enclosed in single quotation mark such as ‘c’
decimalDecimal12Ranges from 1.0

Leave a Reply

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