C# Data Types

Updated on     Kisan Patel

When you develop a program, you occasionally need to work with different types of data, such as numeric, Boolean, and string.

C# has its own set of types, known as data types, to store different types of values.

There are two kinds of data types in C#.

1. Value type

Holds the data within its own memory allocation. Value type includes the following data types.

  • All numeric data types
  • Boolean, Char, and Date
  • Structures
  • Enumerations

2. Reference type

Contains a pointer to another memory location that holds the data. Reference type includes the following data types.

  • String
  • Arrays
  • Classes
  • Delegates

The different data types available in C# are listed in below tables.

C# Data type .Net Data type Size (bytes) Value Range
byte Byte 1 0 to 255 (unsigned)
short Int16 2 -32,768 t0 32,767 (signed)
int Int32 4 -2,147,483,648 to 2,147,487,647
long Int64 8 -9,223,372,036,854,775,808to 9,223,372,036,854,775,807
float Single 4
double Double 8
bool Boolean 1 true or false
char Char 2  contains any single character enclosed in single quotation mark.
e.g. 'a'
decimal Decimal 12

C#

Leave a Reply