Click here to Skip to main content
15,912,756 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.

 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Eddy Vluggen25-Oct-16 11:19
professionalEddy Vluggen25-Oct-16 11:19 
GeneralMessage Removed Pin
25-Oct-16 11:31
professionalN_tro_P25-Oct-16 11:31 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Eddy Vluggen25-Oct-16 11:41
professionalEddy Vluggen25-Oct-16 11:41 
GeneralMessage Removed Pin
25-Oct-16 11:57
professionalN_tro_P25-Oct-16 11:57 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Eddy Vluggen26-Oct-16 2:57
professionalEddy Vluggen26-Oct-16 2:57 
GeneralMessage Removed Pin
26-Oct-16 3:24
professionalN_tro_P26-Oct-16 3:24 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Eddy Vluggen26-Oct-16 3:56
professionalEddy Vluggen26-Oct-16 3:56 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Sander Rossel25-Oct-16 10:39
professionalSander Rossel25-Oct-16 10:39 
The only time var really hurt was when converting from IEnumerable to IQueryable.
Something like the following:
C#
var things = context.Things.ToList(); // Database call here.

// use things without further database calls.
Now what happened, someone removed the call to ToList!
IEnumerable became an IQueryable (which actually IS an IEnumerable).
Nothing broke, it's just that with every usage of the things variable a database call was made.
Things got a lot slower.
Until someone noticed the boo boo.

I'm also not a fan of using var in "generic" code.
Something like IObjectGetter.Get. At least let me know what type of object Get is going to return by not using var.

That's why I don't use var.
I often don't really care about the type that's returned, but I want to see you THOUGHT about what type you expected.
Read my (free) ebook Object-Oriented Programming in C# Succinctly.
Visit my blog at Sander's bits - Writing the code you need.
Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability.
— Edsger W. Dijkstra
Regards,
Sander

GeneralMessage Removed Pin
25-Oct-16 11:03
professionalN_tro_P25-Oct-16 11:03 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Sander Rossel25-Oct-16 11:43
professionalSander Rossel25-Oct-16 11:43 
GeneralMessage Removed Pin
25-Oct-16 12:08
professionalN_tro_P25-Oct-16 12:08 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Sander Rossel25-Oct-16 12:26
professionalSander Rossel25-Oct-16 12:26 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Jeremy Falcon26-Oct-16 8:43
professionalJeremy Falcon26-Oct-16 8:43 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Sander Rossel26-Oct-16 8:46
professionalSander Rossel26-Oct-16 8:46 
GeneralRe: An interesting (or not) thing about C#'s var Pin
CDP180225-Oct-16 10:50
CDP180225-Oct-16 10:50 
GeneralMessage Removed Pin
25-Oct-16 11:05
professionalN_tro_P25-Oct-16 11:05 
GeneralRe: An interesting (or not) thing about C#'s var Pin
TheGreatAndPowerfulOz25-Oct-16 12:20
TheGreatAndPowerfulOz25-Oct-16 12:20 
GeneralRe: An interesting (or not) thing about C#'s var Pin
n.podbielski25-Oct-16 8:09
n.podbielski25-Oct-16 8:09 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Marc Clifton25-Oct-16 8:21
mvaMarc Clifton25-Oct-16 8:21 
GeneralRe: An interesting (or not) thing about C#'s var Pin
n.podbielski25-Oct-16 8:35
n.podbielski25-Oct-16 8:35 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Nish Nishant25-Oct-16 10:14
sitebuilderNish Nishant25-Oct-16 10:14 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Mladen Janković25-Oct-16 10:20
Mladen Janković25-Oct-16 10:20 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Mycroft Holmes25-Oct-16 14:17
professionalMycroft Holmes25-Oct-16 14:17 
GeneralRe: An interesting (or not) thing about C#'s var Pin
Richard Deeming26-Oct-16 3:50
mveRichard Deeming26-Oct-16 3:50 
GeneralRe: An interesting (or not) thing about C#'s var Pin
#realJSOP26-Oct-16 0:06
professional#realJSOP26-Oct-16 0:06 

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.