开发者

'var' keyword in c# [duplicate]

开发者 https://www.devze.com 2023-01-12 17:55 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicates: C# ‘var’ keyword versus explicitly defined variables
This question already has answers here: Closed 12 years ago.

Possible Duplicates:

C# ‘var’ keyword versus explicitly defined variables

Use of var keyword in 开发者_开发百科C#

May I know where to use 'var' keyword and the purpose of using that there ?


Sure, just check one of the many links here : https://stackoverflow.com/search?q=c%23+var+keytword ;)


You can use the var keyword to infer the type of an object.

For example:

//without using the "var" keyword
Dictionary<List<string>,int> myCustomDictionary = new Dictionary<List<string>, int>();

//with the "var" keyword
var myCustomDictionary = new Dictionary<List<string>, int>();

Which is easier to read? :)

0

精彩评论

暂无评论...
验证码 换一张
取 消