J
John Salerno
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.
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.