Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace LearnLinq
- {
- class Program
- {
- static void Main()
- {
- string[] heroes = { "D. Va", "Lucio", "Mercy", "Soldier 76", "Pharah", "Reinhardt" };
- // Method 1: from - where - select query
- var heroesWithI = from hero in heroes
- where hero.Contains("i")
- select hero;
- // Method 2: Method query using lambda - Where()
- //var heroesWithI = heroes.Where(hero => hero.Contains("i"));
- foreach (string s in heroesWithI)
- {
- Console.WriteLine(s);
- }
- //from - select query
- var underscored = from hero in heroes
- select hero.Replace(" ", "_");
- foreach (string s in underscored)
- {
- Console.WriteLine(s);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement