C# series 1.4 : Built-in Data Types - ponda

Breaking

7/05/2017

C# series 1.4 : Built-in Data Types

There are two types of Data type in C#,  Value type and Reference type.

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;


Note that char values are assigned using single quotes and string values require double quotes. You will learn how to perform different operations with variables in the upcoming lessons.

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";

Next : C# series 1.5 : First C# Program

No comments:

Post a Comment