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 5, 2016, 3:21 AM
Nice :)
Bhavik PatelPosted May 5, 2016, 12:29 AM
good one..
Shshi Bhooshan SharmaPosted May 1, 2016, 9:08 AM
Its Good information