Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9010 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > C# Interview Questions > What is the use of var keyword in C#? .. ...

What is the use of var keyword in C#?

Interview question and answer by: SheoNarayan | Posted on: 12/22/2008 | Category: C# Interview questions | Views: 2951 |


Answer:

This is the new feature in C# 3.0. This enable us to declare a variable whose type is implicitly inferred from the expression used to initialize the variable.

eg.

var age = 10;

Because the initialization value (10) of the variable age is integer type of age will be treated as integer type of variable. There are few limitation of the var type of variables.

They are:

#. They can't be initialized as null.
#. They need to be declared and initialized in the same statement.
#. They can't be used as a member of the class.

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from SheoNarayan

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 8:48:05 AM