Re: question on anonymous type
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: Tue, 3 Jun 2008 03:25:08 -0700 (PDT)
On Jun 3, 11:03 am, timor.su...@xxxxxxxxx wrote:
I have a question on anonymous type
Actually, you have a question on implicitly typed local variables.
Anonymous types are the types created when you write code like this:
new { Name="Jon" }
The two features are often used together, but don't have to be.
I can write :
using (StreamWriter writer = new StreamWriter(...))
and I can write this too :
using (var writer = new StreamWriter(...))
What is the best ? Which option should I choose ?
The first seems to be more readable ...
Well, the first contains redundant information - but it's more
expicit. It's largely a matter of taste though. I've found myself
using implicitly typed local variables quite a bit with no loss of
readability.
Jon
.
- Follow-Ups:
- Re: question on anonymous type
- From: timor . super
- Re: question on anonymous type
- References:
- question on anonymous type
- From: timor . super
- question on anonymous type
- Prev by Date: Re: question on anonymous type
- Next by Date: Re: Checking for valid datetime
- Previous by thread: Re: question on anonymous type
- Next by thread: Re: question on anonymous type
- Index(es):