The var keyword: what is a real world example where you would want to use this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The var keyword: what is a real world example where you would want to use this?

25th Apr 2016, 4:51 PM
Chuck Jones
Chuck Jones - avatar
3 Answers
+ 1
times when you are developing and are not sure up front which type you will use. you can change the value to change the type. then at the end, circle back anak explicitly type the declaration.
5th May 2016, 3:21 PM
David Nurbin
0
var keyword is variable type so you need to assign some value mostly use in Linq query
8th Sep 2016, 7:53 PM
Kailash Kothiyal
Kailash Kothiyal - avatar
- 1
It is usually used for complex expressions with complex result type like LINQ queries. And you have to use var keyword for anonymous types because the compiler generates them implicitly and you just can't use them as an explicit type for your variable.
16th Jun 2016, 11:22 AM
Alexander Zabrodin