+ 2

Using lists.

Hello, sololearners. I've been using lists a lot lately and normally declare a list like so: List <Employee> emp = new List <Employee> However, more and more (especially away from the tutorials), I see lists declared using 'var' instead, like so: var emp = new List <Employee> They both work, but I just wondered if there was a particular reason for using var instead? Cheers.

4th Sep 2017, 10:31 AM
Bagshot
Bagshot - avatar
3 Respuestas
+ 4
It is like an all-encompasser of all datatypes, which is convenient than remembering multiple datatypes
4th Sep 2017, 10:39 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
Nice one. Thanks for the replies.
4th Sep 2017, 2:09 PM
Bagshot
Bagshot - avatar
+ 1
Thanks, I thought as much, but seeing as I know what types will populate the list, is the var still necessary?
4th Sep 2017, 11:09 AM
Bagshot
Bagshot - avatar