Re: question on anonymous type
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: Wed, 4 Jun 2008 22:52:32 -0700 (PDT)
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
.
- Follow-Ups:
- Re: question on anonymous type
- From: Arne Vajhøj
- Re: question on anonymous type
- References:
- question on anonymous type
- From: timor . super
- Re: question on anonymous type
- From: Arne Vajhøj
- question on anonymous type
- Prev by Date: Re: Why does Math.Sqrt not take a decimal?
- Next by Date: Re: How to tell when a sound has finished playing ???
- Previous by thread: Re: question on anonymous type
- Next by thread: Re: question on anonymous type
- Index(es):
Loading