```cs using System.Linq; public static class CollectionExtentions { public IEnumerable Show(this IEnumerable collection) { foreach (var item in collection) { Console.WriteLine(item); } return collection; } public static void Hello(this object obj) { Console.WriteLine("Hello {0}") } } 2.Hello(); double[] t = { 5, 8, 5, 2, 3 }; var a = new A() { Id = 10 }; a.Hello(); t.Where(x => x % 2 == 0).Show(); var t = new List { l.Add(new A() { Id = 10 }); l.Add(new A() { Id = 1 }); } l.OrderBy(x => x.Id).Show(); l.Add(new A()); l.AddRange(l); l.Contains(new A()).Show(); l.Any(x => x.Id == 10).Hello(); l.All(x => x.Id == 10).Show(); if (l.Count == 0) { Console.WriteLine(); } l.Clear(); t.Order() Array.Sort(t); t.Show(); IEnumerable Get() { yield return 1; yield return 2; for (int i = 0; i < 3; i++) { yield return i; } } Get().Show(); ``` ```cs static void Lesson5Task() { var sw = new Stopwatch(); sw.Start(); long l1 = 0; for (int i = 0; i < 1_000_000_000; i++) { l1 += i; } sw.Stop(); Thread t1 = new Thread(() => { }); t1.Start(); long l2 = 0; for (int i = 1_000_000_000; i > 1_000_000_000 / 2; i--) { l2 += i; } sw.Stop(); Thread t2 = new Thread(() => { }); t2.Start(); t1.Join(); t2.Join(); l = l1 + l2; sw.Stop(); } ``` ```cs const int MAX = 1_000_000_000; long Sum(int start, int stop); async Task Foo(int delay) { Thread.Sleep(delay); await Task.Delay(1000); Thread.Sleep(delay); } sw.Reset(); sw.Start(); await Foo(); await Foo(); try { await Foo(100); } catch (Exception e) { Console.WriteLine(e.message); } Task.WhenAny(Foo(), Foo()); var task1 = Task.Run(() => Sum(0, MAX / 2)); var task2 = Task.Run(() => Sum(MAX / 2, MAX)); await Task.WhenAll(task1, task2); sw.Stop(); ```