inferring a type

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



This is something that occurred to me a while ago, and again I was thinking about it last night. I noticed how redundant it seems to type an expression like this:

SomeType x = new SomeType();

I asked myself, why do you have to type SomeType twice? I realize the first is a class name and the second is a constructor, but still it's a little redundant.

Anyway, coincidentally, I found a video on MSDN with Anders speaking about a bunch of things, and he happened to bring up this very point. He said one thing they were considering for C# was this possible syntax:

var x = new SomeType();

and the type of x would be inferred from the 'new' expression. I noticed that the video was posted in 2004, so I'm wondering, is this some feature that has snuck into the language since then? If not, why not?

Thanks.
.



Relevant Pages

  • Re: Equity and Freedom
    ... it seems a little redundant. ... the two have different significances. ... dialectics or how bad was Marx's reasoning. ... I checked out your video. ...
    (talk.politics.libertarian)
  • Re: OT- Disgruntled ex employee request legal?
    ... the person in the video has /some/ rights to his own image. ... made redundant. ... release for a nominal fee as compensation for any inconvenience ...
    (uk.rec.motorcycles)
  • Bogosity Episodes on YouTube: Evolution vs. Creation (Part 1 and 2)
    ... This is a response to: http://www.youtube.com/watch?v=2cpNjyVvqK0 ... which is a Creationist lying (redundant) video. ...
    (talk.origins)
  • Re: Canadian redneck road rage
    ... Be sure to watch the whole video. ... Priceless. ... Isn't "Canadian Redneck" redundant? ...
    (misc.fitness.weights)
  • Re: "Oh Sunni! Oh, Shiite! Lets fight the Jews."
    ... Jette Goldie wrote: ... What if I've discovered I can hire a _smaller_ bunch of very competent ... Then you've effectively made the surplus people "redundant". ... them their redundancy money ("severance pay") and let them go. ...
    (rec.arts.sf.fandom)