0% found this document useful (0 votes)
47 views

3 C Sharp Programing Construct and GC

The document discusses key concepts in C# including value types and reference types, variables, arrays, methods, method overloading, and provides examples of a jagged array and printing a Fibonacci series. It explains that C# has primitive and reference data types, with value types stored on the stack and reference types stored in the heap, and provides examples of boxing, unboxing, and declaring and initializing variables and arrays.

Uploaded by

Roshan212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

3 C Sharp Programing Construct and GC

The document discusses key concepts in C# including value types and reference types, variables, arrays, methods, method overloading, and provides examples of a jagged array and printing a Fibonacci series. It explains that C# has primitive and reference data types, with value types stored on the stack and reference types stored in the heap, and provides examples of boxing, unboxing, and declaring and initializing variables and arrays.

Uploaded by

Roshan212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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
Stack
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
identifiers
Operators:

ARRAYS:

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++)
{
Console.Write(myJary[i][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;
return(r);
}
int x = Sum(4,5);
Method Overloading: is the process of having different methods with same name
but different signature.

Questions:
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

You might also like