Re: question on anonymous type

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
.