You are on page 1of 3

C # Language Constructs 1

When we talk about any programing language the first thing that comes to picture
are the data types.
In C# there are 2 kinds of data types:
1. Value Types (Primitive data types, Structs and enumerations) stored in
2. Reference Types (Class, Interface, Delegates) stored in Heap

The base class for all types is System.Object

Boxing: Conversion of Value Types to Reference Type

Unboxing: Conversion of Reference Types to Value Type

Variable: Is the name given to a temporary memory location where data of

particular data type is stored temporarily during the execution of a program.
int I; int x = 10; // this reserves 4 bytes in memory to store an integer value
Key Words: are words defined in the language and they cannot be used for


An array is an ordered sequence of homogenous elements i.e. of same type.

Array, Multidimensional Array and Jagged Array.

Example of Jagged Array:

int[][] myJary = new int[5][];
for (int i = 0; i < myJary.Length ; i++)
myJary[i] = new int[i + 5];
for (int i = 0; i < myJary.Length; i++)
for (int j = 0; j < myJary[i].Length; j++)

Method: is a set of code under a unique name within the scope which accepts some
input values as parameters and may return value of a particular data type.
e.g. :
int Sum( int I, int j)
Int r = I + j;
int x = Sum(4,5);
Method Overloading: is the process of having different methods with same name
but different signature.

1. Print Fibonacci series till 10th term // 1 1 2 3 5 8 13 21
2. Write a method to accept integer value as argument and return the Factorial
for it recursively
3. Create an array containing 10 random integers and then print the integers in
ascending order. // Do not use Array.Sort