C# Data Type


C# Data types are categorized into following three types.

C# Data Type
C# Data Type

1. Values Types

Values types are actual data that directly contain their data & allocated on stack. Values types derived from class ‘System.ValueType’

# Datatype Represents Range Default Value .Net Class
1 bool Boolean Value True(1) or False(0) False(0) Boolean
2 byte 8-bit unsigned integer 0 to 255 0 Byte
3 char 16-bit Unicode character U +0000 to U +ffff ‘\0’ Char
4 decimal 128-bit precise decimal values with 28-29 significant digits ±1.0 × 10e−28 to ±7.9 × 10e28 0.0M Decimal
5 float 32-bit single-precision floating point type -3.402823e38 to 3.402823e38 0.0F Single
6 double 64-bit double-precision floating point type -1.79769313486232e308 to 1.79769313486232e308 0.0D Double
7 int 32-bit signed integer type -2,147,483,648 to 2,147,483,647 0 Int32
8 long 64-bit signed integer type -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0L Int64
9 sbyte 8-bit signed integer type -128 to 127 0 Byte
10 short 16-bit signed integer type -32,768 to 32,767 0 Int16
11 ushort 16-bit unsigned integer type 0 to 65,535 0 Uint16
12 uint 32-bit unsigned integer type 0 to 4,294,967,295 0 Uint32
13 ulong 64-bit unsigned integer type 0 to 18,446,744,073,709,551,615 0 Uint64

2. Reference Types

Reference type contain address of the memory where the data is store. 2 variables can reference to the same object so that operation on one variable can affect the object referenced by the other variable.

List of reference type in C# :

  1. Class : Basically class describe all attributes of of objects as well as the method that implement the behavior of member object. Class contain data and behavior of an entity. Classes are declared using the keyword class, as shown in the following example.
     class Student
        //  properties, Methods,fields, events, delegates   
        // and nested classes go here.  
  2. Object : Object is a basic unit of a system. It is an instance of class. An Object is an entity that has behavior, attributes and identity. Attributes and behavior of an object are defined by class definition.
  3. String : String use to assign any type of value to the variable. string is an alias for String in the .NET Framework
    string a = "good " + "morning";

3. Pointer Types

It store the memory address of another type.

char* a;
int* b;


Leave a Comment