Monday, June 15, 2009

My HelloWorld LINQ Example

I know it is sad, but up until today I hadn't ever written a single LINQ query. So, for future prosterity, here is my hello world example.

 string[] s = { "test", "hello world", "mamma", "zack", "aaa","xxx" };
// LINQ
var subset = from z in s where z != "hello world"
orderby z descending select z;
int i = 0;
foreach (var l in subset)
{
Response.Write(
"Item " + i.ToString() + " = " + l + "<br />");
i++;
}

No comments: