blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Merrick Chaffer's Blog

Using linq in your C# code

Just came across a nasty gotcha today, where by we were trying to use the new C# 3.5 syntax

var x = from item in items select new Item { ItemName = item.Name };

and getting a compile error. Turns out this was due to the need to have the following using statement (that doesn't come up in a smart tag prompt when you're writing linq),

using System.Linq;

To be fair the compiler error was suggesting exactly this.

Published 08 May 2008 15:21 by merrick.chaffer
Filed under: , , ,

Comments

 

Ian Shimmings said:

When you create a new class file in VS2008, System.Linq is one of the automatically included namespaces.

May 8, 2008 17:54
Anonymous comments are disabled
Powered by Community Server (Personal Edition), by Telligent Systems