Last active
February 24, 2018 18:34
-
-
Save sometowngeek/4f419e56c86c986fe5e5d7535f360118 to your computer and use it in GitHub Desktop.
LINQ Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinqExample | |
{ | |
public static void Main(String[] args) | |
{ | |
List<SomeMap> mapList = new List<SomeMap>(); | |
mapList.Add(new SomeMap(1, "Main Office")); | |
mapList.Add(new SomeMap(2, "Bedroom")); | |
mapList.Add(new SomeMap(3, "Art Room")); | |
var result = mapList | |
.Where(m => m.Name.Contains("Art")) | |
.Select(c => c.Name) | |
.ToList(); | |
foreach (var i in result) | |
{ | |
Console.WriteLine(i); | |
} | |
Console.ReadKey(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeMap | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public SomeMap(int id, string name) | |
{ | |
this.Id = id; | |
this.Name = name; | |
} | |
public SomeMap() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment