inferring a type
- From: John Salerno <johnjsal@xxxxxxxxxxxxxxx>
- Date: Fri, 04 Nov 2005 19:10:19 -0500
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. .
- Follow-Ups:
- Re: inferring a type
- From: John Richardson
- Re: inferring a type
- From: Mattias Sjögren
- Re: inferring a type
- Prev by Date: Serialized class from XSDObjectGen results in invalid char at position 1,1
- Next by Date: Re: Runtime Type Conversion
- Previous by thread: Serialized class from XSDObjectGen results in invalid char at position 1,1
- Next by thread: Re: inferring a type
- Index(es):
Relevant Pages
|