Var was introduced in C# 3.0 and dynamic was introduced in C# 4.0. When we define a variable as var that means we cannot change its data type after first initialization and data type checking at compile time. When we define a variable as dynamic that means we can change its data type for any number of times during program execution and data type checking at run time.
- class vardynamic
- {
- public void show()
- {
- var a = "Hello var";
- dynamic b = “Hello dynamic”;
- Console.WriteLine("a: {0}", a);
- Console.WriteLine("b: {0}", b);
- //a = 10;
- //Console.WriteLine(a);
- b = 10;
- Console.WriteLine(b);
- }
- }


Satish Kumar VadlavalliPosted May 4, 2016, 11:21 PM EDT
Nice :)
Bhavik PatelPosted May 4, 2016, 8:29 PM EDT
good one..
Shshi Bhooshan SharmaPosted May 1, 2016, 5:08 AM EDT
Its Good information