Re: question on anonymous type



On Jun 5, 3:34 am, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
What is the best ? Which option should I choose ?
The first seems to be more readable ...

I would go for the first as being more readable. Most
C# programmer will be used to reading the type first.

At the moment, yes. I think things will change as C# 3 becomes more
widely known.

And you will not be typing the class name twice. The
IDE should propose it the second time.

True, but it's not really about typing. It's about information
redundancy.

Ironically, the thing which the OP *didn't* do which I often would is
use a base type or interface:

using (TextWriter writer = new StreamWriter(...))

that adds information - it tells the reader that actually, any
TextWriter will do for what we need to call - it just so happens that
it uses StreamWriter at the moment. At the point you're adding this
extra information, there is no longer redundancy for implicit typing
to remove.

Jon
.


Loading