Skip to content

Instantly share code, notes, and snippets.

@dotnetdude
dotnetdude / gist:2508048
Created April 27, 2012 09:58
Csharp: Create a new list from the first items of another list
// Take the first 3 items from list 'list' and create a new list with them
var shortList = list.Take(3).ToList();
@dotnetdude
dotnetdude / gist:2508010
Created April 27, 2012 09:56
Csharp: Filter lists
var list = new List<string>() {"Asia", "Africa", "North America", "South America", "Antartica", "Europe", "Australia"};
// Get all the items from the list that start with
// an 'A' and have 'r' as the 3rd character
var filteredList = list.Where(item => item.StartsWith("A")).Where(item => item[2] == 'u').ToList();
@dotnetdude
dotnetdude / gist:2489484
Created April 25, 2012 12:43
SQL: Find a table column on SQL Server
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = 'email' )
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%PART_OF_NAME%' )