Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hey guys
I cant define var datatype uder my method , anybody knows why ?
Posted
Comments
joshrduncan2012 21-Jun-13 17:51pm    
It depends on what the context of your program is. You need to provide more information as to what you have accomplished so far and where you are trying to insert a var data type.
Sergey Alexandrovich Kryukov 21-Jun-13 22:47pm    
More exactly, not that it depends on the context — this is not a type at all, and the actual type is inferred. Please see my answer.
—SA

1 solution

C# "var" is not a type at all. You cannot find it in Intellisense. This is a keyword which serves as a placeholder of the type in a variable declaration, and only in the case when the actual type can be inferred from the initializing expression. To understand how it works, you should learn about type inference: http://msdn.microsoft.com/en-us/vstudio/jj131514.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900