Evolution of C Sharp Language: Picture Blog

I was working on something and suddenly a mail popped up. I did not know the sender but I found he/she was a job aspirant. I found him/her very impatient and gist of his/her mail was, “Sir tomorrow I got a job interview. Could you please help me with different versions of C Sharp with specific features in each versions? I just want to know the features name “

I found this question very interesting. Since majority of the time we focus on implementation of a feature. We discuss how a particular feature can be implemented in greater extent but we tend to forget in which version of C Sharp that particular feature got introduced. For a junior level programmer interview, this could be a vital question that list different features of C Sharp version wise. I am trying to answer this question pictorially below,


I am sure taking a high level look on this picture before going to interview could be a help. I hope you find this picture post useful. Thanks for reading.

Method Caller Information in C Sharp 5.0

Before we understand Method Caller Information feature of C# 5.0, we need to understand Optional Parameter feature of C# 4.0.

C Sharp 4.0 introduced Optional Parameter feature . According to this feature, in function call only required parameters are needed to be passed. If value of Optional Parameters are not provided then they will take default constant value. To understand it better, let us take following function as example.

static void Display(string Name, int age,string Nationality="Indian")

Console.WriteLine("Hey " + Name + " you are " + age + " old " + Nationality);

In function Display, Nationality is an optional parameter. So while calling this function you will get intellisense suggesting you that if not provided parameter Nationality will take constant string value “Indian”


You can call Display function omitting value of parameter Nationality as following

static void Main(string[] args)
Display("dj", 28);


In output you will notice that value of parameter Nationality is set to default string constant “Indian”

Now you can see that Optional Parameters has taken the default constant value. C# 5.0 gives us liberty or allow us to attribute optional parameter with caller info attributes. By providing caller info attributes at the runtime optional parameter value will be replaced by dynamic values for caller info attributes. There are three caller info attributes are available,


Let us go ahead and rewrite Display function with Method Caller Information attribute on optional parameters.


You see in above function definition [see the rectangle], we have attributed three optional parameters with method caller information. We can display method caller information as following,

static void Display(string Name,
int age,
string Nationality="Indian",
[CallerMemberName] string Caller = "",
[CallerFilePath] string file="",
[CallerLineNumber] int line=0)

Console.WriteLine("Hey " + Name + " you are " + age + " old " + Nationality);
Console.WriteLine("This function is called  from member " + Caller + " file " + file + " line " + line);

Now when you call the function you will get method caller information printed. Expected output would be as following

Method Caller Information is particularly very useful in logging of the application. For high level logging, I would consider using Method Caller Information attributes along with optional parameters. I hope you find this post on Method Caller Information in C# 5.0 useful. Thanks for reading.

What is Namespace in WinJS

Let us first try to understand, why we need Namespace? I will try to explain you with an example, let us suppose you have a function named GreetingMessage in JS file named Library.js


Now you need to use this function on default.js. When you try to call that function from other js file , you get following exception.



Essentially, you cannot access a function or variable outside its scope. Namespace in WinJS library allows you to access a function outside its scope.

  • Namespace allows you to access a function outside its scope.
  • Namespace allows you to use a function in different files along with file it is defined.
  • Namespace helps you to organize your code
  • Any type created in Namespace can be referenced outside the scope of Namespace

Now let us see that how can we define a Namespace in WinJs . You can define Namespace by calling the define function



There are two parameters need to be passed to create Namespace.

  1. Namespace name is a string
  2. Members of the Namespace as object

You can create a Namespace in Library.js as following,

(function () {

 function GreetingMessage() {

return "Hello from WinJS";


WinJS.Namespace.define("MyLibrary.Function", {
 GreetingMessage: GreetingMessage


There are few points you need to take care here

  • Enclosed all the Namespace definition in self executed function
  • Make sure you are not forgetting the braces at the end.
  • We have defined a function named GreetingMessage
  • We have defined a namespace and function inside that can be accessed as following


We have defined a Namespace and now we want to access the function GreetingMessage() on the default.js file. To do this first step you need to do is to refer MyLibrary.js on default.html file. You can refer that as following,

Now you can access GreetingMessage() function on default.js as following ,

var res = MyLibrary.Function.GreetingMessage();
 var output = document.getElementById("output");
 output.innerHTML = res;

In this way by using Namespace, you can access functions and objects in different files and beyond scope of the declaration. I hope you find this post useful. Thanks for reading.

What is Associative Array in JavaScript?

In this post I discussed about Arrays in JavaScript. We access elements of JavaScript array using numeric index. For example, if you want to access 3rd element of a JavaScript array, you will do that as following


If you want to traverse through each element of the array you can do that in loop. JavaScript also allows you to store and access elements in the array in using string index than numeric index.


You can create Associative Array in JavaScript as following,


We are assigning values in array using string index. You can access a particular element with string index name. We can access name information from student information as following


One problem working with Associative Array is that we can not traverse through array elements in a loop. Associative Array can be best utilized with Array with Arrays is JavaScript. Read here about Array of Arrays

Let us take above example of student array. If we want more than one student to be stored then, we can create student array as following


Then we can create associative Student Array as following


Now if push student in arrayofStudent array.


If we want to access name of the first student from the array, we can do that as following,


For your reference code is given below we used in explaining Associative Array.

 <script type="text/javascript" >
 var arrayofStudent=[];
 var student1 = [];
 student1["rollnumber"] = 19;
 student1["name"] = "John";
 student1["grade"] = "A";
 var student2 = [];
 student2["rollnumber"] = 11;
 student2["name"] = "David";
 student2["grade"] = "B";

<span style="font-size: 12pt;"></span>


<span style="font-size: 12pt;"></span>

In this way you can work with Associative Array in JavaScript. I hope you find this post useful. Thanks for reading. 

Working with Array of Arrays in JavaScript


If you have worked with languages like C, C++ or C# then you must be aware with the concept of multidimensional array. Multidimensional array implies arrays of array. In a two dimensional array, there would be rows and columns. A 3*5 two dimensional array can be shown as below,

0,0 0,1 0,2
1,0 1,1 1,2
2,0 2,1 2,2
3,0 3,1 3,2
4,0 4,1 4,1

Even though you cannot declare a multidimensional array directly in JavaScript though you can have Arrays of Array in JavaScript.

You can define a two dimensional array as following in JavaScript



In above code

  • First we defined a base array
  • Then we created two chid arrays. These arrays will constitute different rows of the base array.
  • Each child array is of different size.
  • Assigning each chid array as one of the rows of base array. 

In last line of above code listing, we are printing value of 1st row and 4th column of base array. We will get output as following,

On noticing above code listing you will find that chid array is of different size. In JavaScript chid arrays can be of different size. Essentially you can have three dimensional array in JavaScript as well. You can define that as following code listing,


In above code listing,

  • We are defining array named grandparents. This is the base array.
  • We are defining array named parents. Grandparents can have parents.
  • We are defining array names child. Parents can have child.

We want to print “steve”. Steve is second element of child2 array. child2 array is second element of parents1 array. parents1 array is first element of grandparents array. so we can fetch steve with following index value on grandparents array


As output you will get steve printed as following,

For your reference code of two dimensional array and three dimensional array in JavaScript is given below,

<script type="text/javascript" >
 //Two Dimensional Array
 var baseArray = [];
 var chidArray1 = ["a", "b", "c", "d", "e"];
 var chidArray2 = ["1","2","3","4","5","6","7","8"];
 baseArray[0] = chidArray1;
 baseArray[1] = chidArray2;
 //Three Dimensional Array
 var grandparents = [];
 var parents1 = [];
 var parents2 = [];
 var child1 = ["john", "ram"];
 var child2 = ["mona", "steve", "mark"];
 var child3 = [];
 var child4 = ["chris"];
 parents1[0] = child1;
 parents1[1] = child2;
 parents2[0] = child3;
 parents2[1] = child4;
 grandparents[0] = parents1;
 grandparents[1] = parents2;
 console.log("printing Steve");


In this way you can work with Arrays of Array in JavaScript. I hope you find this post useful. Thanks for reading.