I don't get var(codeheaven.info)

submitted by johnrudyjohnrudy(150) 3 years, 10 months ago

Brief rant about C#'s var keyword. Short version: Aside from anonymous types ... what's the big deal?

1 comment |category: |Views: 31

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by JemmJemm(9604) 3 years, 10 months ago 0

I couldn't comment in your blog, so I'll do it in here:

I think the var was put in C# 3.0 primarily to support LINQ-queries that return anonymous types. In LINQ you can return any kind of objects with variable amount of columns or properties (defined in the select-part).

This ScottGu's article explains it well from the LINQ-perspective, too:
http://weblogs.asp.net/scottgu/archive/2007/05/15/new-orcas-language-feature-anonymous-types.aspx

Reply

information Login or create an account to comment on this story