There are two types of Data type in C#, Value type and Reference type.
1. Value Types
1. Value Types
- When a variable is declared using one of the basic, built in data types or a user defined structure, it is a value type, exception for this is string which is a reference type.
- a value type stores its contents in memory allocated on the stack.
Example :
int - integer.
float - floating point number.
double - double precision version of float.
char - a single character.
bool - Boolean that can have only one of two values: true or false.
int x = 42;
double pi = 3.14;
char y = "Z";
bool isOnline = true;
2. Reference type
A reference type, such as an instance of a class or an array, is allocated in a different area of memory called the heap.
string - a sequence of characters.
string firstName = "David";
string firstName = "David";
Next : C# series 1.5 : First C# Program
No comments:
Post a Comment