What is the basic difference between "var" keyword in Javascript and C# ?

 Posted by Akiii on 12/13/2011 | Category: C# Interview questions | Views: 4732 | Points: 40

In C#, we have "dynamic" keyword. This dynamic keyword is somewhat similar to javascript's "var" . Here, both create a variable whose type will not be known until runtime, and whose misuse will not be discovered until runtime. C#'s var creates a variable whose type is known at compile time.

For example:-

dynamic dt= new DateTime();


//compiles fine but gives an error at runtime

Thanks and Regards

Asked In: Some Interviews | Alert Moderator 

Comments or Responses

Login to post response