C# Data Types – Predefined Types

There are 16 predefined types in C#. These types can be divided into:

  1. Simple Types(13)
  2. Non-Simple Types(3)

All these predefined types are in lowercase characters.

The C# predefined types map directly to underlying .NET Base types.

The C# names are the aliases for these .NET base types.

Simple Types

The simple types include:

  1. Numeric Types(11). These include:
    • Integers : Signed and Unsigned.
    • Floating Point Numbers : Floats and Double.
    • Decimal : High precision decimal type.
  2. Unicode Character type – Char.
  3. Boolean : bool represents true or false.
Name Description Range Base Type Default Value
sbyte 8-bit signed integer -128 to 127 System.SByte 0
byte 8-bit unsigned integer 0 to 255 System.Byte 0
short 16-bit signed integer -32,768 to32,767 System.Int16 0
ushort 16-biy unsigned integer 0 to 65,535 System.UInt16 0
int 32-bit signed integer -2,147,483,648 to 2,147,483,647 System.Int32 0
uint 32-bit unsigned integer 0 to 4,294,967,295 System.UInt32 0
long 64-bit signed integer -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 System.Int64 0
ulong 64-bit unsigned integer 0 to 18,446,744,073,709,551,615 System.UInt64 0
float Single precision floating point -1.5e45 to 3.4e38 System.Single 0.0f
double Double precision floating point -5e324 to 1.7e308 System.Double 0.0d
decimal 28-bit significant digit precision decimal ±1.0e28 to ±7.9e28 System.Decimal 0m
bool Boolean value true, false System.Boolean false
char Unicode character U+0000 to U+ffff System.Char x0000

Non-simple Types

The non-simple types include:

  1. string – a seqeunce of unicode characters.
  2. object – base type for creation of all other types.
  3. dynamic – usable when working with assemblies written in dynamic languages.
Name Description Base Type
object base class for all types including simple types System.Object
string sequence of zero or more Unicode characters System.String
dynamic Type designed to be used with assemblies written in dynamic languages No base type

C# Predefined Types


Share an Example

Share an Example

What is the capital of Egypt? ( Cairo )