Byte |
8-bit unsigned integer |
0 to 255 |
1 |
Value Type |
Stack |
255 |
byte b = 200; byte age = 25; // Age of a person |
Sbyte | 8-bit signed integer | -128 to 127 | 1 |
Value Type | Stack | 127 | sbyte sb = -100; sbyte temp = -30; // Temperature in winter |
short | 16-bit signed integer | -32,768 to 32,767 | 2 | Value Type | Stack | 32,767 | short s = 30000; short students = 500; // Students in school |
ushort | 16-bit unsigned integer | 0 to 65,535 | 2 | Value Type | Stack | 65,535 | ushort us = 60000; ushort population = 60000; // Village pop |
int | 32-bit signed integer | -2,147,483,648 to 2,147,483,647 | 4 | Value Type | Stack | 2,147,483,647 | int age = 25; int salary = 35000; // Monthly salary |
uint | 32-bit unsigned integer | 0 to 4,294,967,295 | 4 | Value Type | Stack | 4,294,967,295 | uint u = 3000000000; uint stock = 200000; // Product stock |
long | 64-bit signed integer | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | 8 | Value Type | Stack | 9,223,372,036,854,775,807 | long l = 9000000000; long distance = 15000000000; // Space distance |
ulong | 64-bit unsigned integer | 0 to 18,446,744,073,709,551,615 | 8 | Value Type | Stack | 18,446,744,073,709,551,615 | ulong ul = 10000000000; ulong views = 10000000000; // Video views |
float | 32-bit single precision floating point | ±1.5e−45 to ±3.4e38 | 4 | Value Type | Stack | Precision: ~7 digits | float f = 5.5f; float pi = 3.14f; // Value of Pi |
double | 64-bit double precision floating point | ±5.0e−324 to ±1.7e308 | 8 | Value Type | Stack | Precision: ~15-16 digits | double d = 19.99; double price = 199.99; // Product price |
decimal | 128-bit high-precision floating point | ±1.0e−28 to ±7.9e28 | 16 | Value Type | Stack | Precision: ~28-29 digits | decimal dec = 1000.50m; decimal money = 100000.75m; // Bank balance |
char | Single 16-bit Unicode character | Any Unicode character | 2 | Value Type | Stack | Single character only | char grade = 'A'; char grade = 'A'; // Student grade |
bool | True or False | True, False | 1 | Value Type | Stack | Only two values | bool isActive = true; bool isActive = true; // Is account active? |
string | Sequence of characters (immutable) | Any text | Dynamic (length × 2) | Reference Type | Heap | Limited b y memory | string name = "Megha"; string name = "Megha"; // Person's name |
dynamic | Runtime type binding | Any data type at runtime | Dynamic | Reference Type | Heap | Type decided at runtime | dynamic val = 10; val = "Hi"; dynamic value = 10; value = "Hello"; |
var | Compile-time type inference | Any type (decided by compiler) | Based on type | Reference/Value | Stack / Heap | Cannot change type once assigned | var x = 100; var city = "Delhi"; // Auto type detection |
array | Collection of similar data types | Fixed length | Depends on elements | Reference Type | Heap | Fixed size, same data type | int[] arr = {1,2,3}; int[] marks = {90, 85, 95}; |
nullable | Value type that can hold null | Null or actual value | Based on type | Value Type | Stack | Allows null assignment | int? age = null; int? age = null; |
Pointer | Stores memory address (unsafe code) | Memory address | 4 / 8 | Pointer Type | Stack / Heap | Used in unsafe context only | int* ptr; // Pointer example |