Re: question on anonymous type

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Arne Vajhøj wrote:

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

I doubt it.

C# 3 will become widely known.

But most C# developers will have learned C# in earlier versions
and many of them will also use other languages from let us call
it "the C syntax family".

I think though that var is a special case because in some circumstances
its the only effective way to reference a type, anonymous types gained
from projection out of a linq query for example.


var report = from line in SomeEnumeration
select new
{
Value = line.SomeValue,
AnotherValue = line.AnotherValue
}

foreach (var reportline in report)
{
//...
}


I this will become common enough for var to be considered "normal" C#
syntax.

Cheers Tim.



--

.