using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection.Metadata; namespace Features { class Program { // Modelling a company in this project static void Main(string[] args) { /* Generic Delegate & Lambda Expression */ Func square = x => x*x;// Define a generic delegate functions named square for square operation Func add = (x, y) => { int temp = x + y; return temp; }; Action write = x => Console.WriteLine(x); write(square(add(3, 5))); /* LINQ & C# */ IEnumerable developers = new Employee[] { new Employee {Id = 1, Name = "Scott"}, new Employee {Id = 2, Name = "Chris"} }; List sales = new List() { new Employee {Id = 3, Name = "Alex"} }; Console.WriteLine(sales.MyLinqCount()); var enumerator = developers.GetEnumerator(); while (enumerator.MoveNext()) { Console.WriteLine(enumerator.Current.Name); // .Current return value of current enumerator } foreach (var person in developers) { Console.WriteLine(); } foreach (var employee in developers .Where(e => e.Name.Length == 5) .OrderBy(e => e.Name)) { Console.WriteLine(employee.Name); } // LINQ (Method syntax) var query = developers.Where(e => e.Name.Length == 5) .OrderBy(e => e.Name); // LINQ (Query syntax) var query2 = from developer in developers where developer.Name.Length == 5 orderby developer.Name descending select developer; foreach (var employee in query) { Console.WriteLine(employee.Name); } foreach (var employee in query2) { Console.WriteLine(employee.Name); } } } }