static void Main(string[] args) { void show(Programists[] array) { Console.WriteLine("Mutation level:"); foreach (Programists x in array) { if (x.MutLev < 0) { Console.WriteLine($"{x.Name} is deleted!"); } else { Console.WriteLine($"{x.Name} mutation level {x.MutLev}"); } } Console.WriteLine(); } ProgCont contr = new ProgCont(); Programists[] norm = new Programists[4]; norm[0] = new Programists(5, 2); norm[1] = new Programists(5, 1); norm[2] = new Programists(3); norm[3] = new Programists(4); show(norm); contr.Mutation += norm[1].OnMutLev; contr.contr(); show(norm); contr.Mutation += norm[3].OnMutLev; contr.Del += norm[2].DeletePr; contr.contr(); show(norm); priv hi = () => Console.WriteLine("Hello, it's delegates"); summa summ = (x, y, z) => z < 10? x + y:x * y; hi(); Console.WriteLine(summ(4, 3, 12)); StringBuilder str = new StringBuilder("KSFV F S.eA Po"); Action <StringBuilder> action; action = StringMethods.AddBAfterS; action += StringMethods.DeleteSpaces; action += StringMethods.AddSpacesAfterPoints; action += StringMethods.DeleteCommas; action += StringMethods.DeleteLetterA; action(str); Console.WriteLine($"{str}\n"); }
static void Main(string[] args) { void show(Programists[] array) { Console.WriteLine("Mutation level:"); foreach (Programists x in array) { if (x.MutLev < 0) { Console.WriteLine($"{x.Name} is deleted!"); } else { Console.WriteLine($"{x.Name} mutation level {x.MutLev}"); } } Console.WriteLine(); } ProgCont contr = new ProgCont();//создаем контроллер Programists[] norm = new Programists[4]; norm[0] = new Programists(5, 2);//объект с прогерами norm[1] = new Programists(5, 1); norm[2] = new Programists(3); norm[3] = new Programists(4); show(norm); contr.Mutation += norm[1].OnMutLev; //на событие мутэшн подписывается метод онмутлевел для 2 прогера contr.contr(); //проверка,те методы которые подписались выполняются show(norm); contr.Mutation += norm[3].OnMutLev; //увеличение мутл для 4 прогера contr.Del += norm[2].DeletePr; //подписываем удаление 3 прогера contr.contr(); show(norm); priv hi = () => Console.WriteLine("Hello, it's delegates");//1 лямда выражение(короткая запись функция) summa summ = (x, y, z) => z < 10? x + y:x * y; hi(); Console.WriteLine(summ(4, 3, 12)); StringBuilder str = new StringBuilder("KSFV F, S.eA Po"); Action <StringBuilder> action; action = StringMethods.AddBAfterS; action += StringMethods.DeleteSpaces; action += StringMethods.AddSpacesAfterPoints; action += StringMethods.DeleteCommas; action += StringMethods.DeleteLetterA; action(str); Console.WriteLine($"{str}\n"); }
static void Main(string[] args) { void show(Language[] array) { Console.WriteLine("Language:"); foreach (Language x in array) { Console.Write($"{x.Name} -- "); Console.WriteLine($"Свойство: {x.Property}"); } Console.WriteLine(); } ProgCont contr = new ProgCont(); Language[] norm = new Language[4]; norm[0] = new Language(); norm[1] = new Language(5); norm[2] = new Language(3, "C++"); norm[3] = new Language(4, "Python"); show(norm); contr.Rename += norm[1].Newname; contr.Run(); show(norm); contr.Rename += norm[2].Newname; contr.New_property += norm[2].change; contr.New_property += norm[0].change; contr.Run(); show(norm); priv hi = () => Console.WriteLine("Hello, it's delegates"); summa summ = (x, y, z) => z < 10 ? x + y : x * y; hi(); Console.WriteLine(summ(4, 3, 12)); StringBuilder str = new StringBuilder("KSFV F S.eA Po"); Action <StringBuilder> action; action = Operation.AddBAfterS; action += Operation.DeleteSpaces; action += Operation.AddSpacesAfterPoints; action += Operation.DeleteCommas; action += Operation.DeleteLetterA; action(str); Console.WriteLine($"{str}\n"); Console.ReadLine(); }