Click here to Skip to main content
15,907,000 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: c# var Pin
Member 289602024-Jun-20 7:24
Member 289602024-Jun-20 7:24 
GeneralRe: c# var Pin
ZurdoDev24-Jun-20 7:39
professionalZurdoDev24-Jun-20 7:39 
AnswerRe: c# var Pin
Fabio Franco24-Jun-20 12:40
professionalFabio Franco24-Jun-20 12:40 
AnswerRe: c# var Pin
zezba900024-Jun-20 12:41
zezba900024-Jun-20 12:41 
AnswerRe: c# var Pin
KateAshman24-Jun-20 22:13
KateAshman24-Jun-20 22:13 
AnswerRe: c# var Pin
JohaViss6125-Jun-20 5:40
professionalJohaViss6125-Jun-20 5:40 
AnswerRe: c# var Pin
BDieser26-Jun-20 4:28
BDieser26-Jun-20 4:28 
AnswerRe: c# var Pin
Member 1409260529-Jun-20 22:04
Member 1409260529-Jun-20 22:04 
There is no advantage. If you just write a scribble, then always using var is Ok. But if you write production-level code, var is sloppy style and thus an absolute no-go. Before IntelliSense was able to automatically convert the var's in your source code to the correct type, var was even an evidence of a programmer not knowing what type they're using.

Only exception: Use var to avoid writing the same type twice in the same line.

Bad
C#
List<string> list = new List<string>();

Good
C#
var list = new List<string>();

Because then, when you want to change the type, let's say from List to HashSet, you only have to change it once. IntelliSense also suggests this, at least in VS 2017.
GeneralCCC Solution - 2020-06-23 Pin
Randor 23-Jun-20 2:26
professional Randor 23-Jun-20 2:26 
GeneralRe: CCC Solution - 2020-06-23 Pin
Richard MacCutchan23-Jun-20 3:09
mveRichard MacCutchan23-Jun-20 3:09 
GeneralRe: CCC Solution - 2020-06-23 Pin
Randor 23-Jun-20 4:06
professional Randor 23-Jun-20 4:06 
GeneralRe: CCC Solution - 2020-06-23 Pin
Richard MacCutchan23-Jun-20 4:14
mveRichard MacCutchan23-Jun-20 4:14 
QuestionWhich graph type would you use? Pin
Joan M23-Jun-20 1:58
professionalJoan M23-Jun-20 1:58 
AnswerRe: Which graph type would you use? Pin
Garth J Lancaster23-Jun-20 2:02
professionalGarth J Lancaster23-Jun-20 2:02 
AnswerRe: Which graph type would you use? Pin
musefan23-Jun-20 2:31
musefan23-Jun-20 2:31 
GeneralRe: Which graph type would you use? Pin
Joan M23-Jun-20 3:00
professionalJoan M23-Jun-20 3:00 
GeneralRe: Which graph type would you use? Pin
W Balboos, GHB23-Jun-20 5:17
W Balboos, GHB23-Jun-20 5:17 
AnswerRe: Which graph type would you use? Pin
OriginalGriff23-Jun-20 2:34
mveOriginalGriff23-Jun-20 2:34 
GeneralRe: Which graph type would you use? Pin
Slacker00723-Jun-20 2:35
professionalSlacker00723-Jun-20 2:35 
GeneralRe: Which graph type would you use? Pin
Greg Utas23-Jun-20 2:53
professionalGreg Utas23-Jun-20 2:53 
GeneralRe: Which graph type would you use? Pin
OriginalGriff23-Jun-20 3:00
mveOriginalGriff23-Jun-20 3:00 
GeneralRe: Which graph type would you use? Pin
Greg Utas23-Jun-20 3:08
professionalGreg Utas23-Jun-20 3:08 
GeneralRe: Which graph type would you use? Pin
Joan M23-Jun-20 3:02
professionalJoan M23-Jun-20 3:02 
GeneralRe: Which graph type would you use? Pin
DerekT-P24-Jun-20 6:27
professionalDerekT-P24-Jun-20 6:27 
AnswerRe: Which graph type would you use? Pin
Marc Clifton23-Jun-20 3:23
mvaMarc Clifton23-Jun-20 3:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.