diff --git a/DevTips/DevTips/Program.cs b/DevTips/DevTips/Program.cs index b335e67..18c90cb 100644 --- a/DevTips/DevTips/Program.cs +++ b/DevTips/DevTips/Program.cs @@ -20,6 +20,9 @@ class Program // FuncClient.Client(); // Predicate - PreicateClient.Client(); + // PreicateClient.Client(); + + // Delegate + DelegateClient.Client(); } } diff --git a/DevTips/DevTips/Tips/DelegateClient.cs b/DevTips/DevTips/Tips/DelegateClient.cs new file mode 100644 index 0000000..93136d6 --- /dev/null +++ b/DevTips/DevTips/Tips/DelegateClient.cs @@ -0,0 +1,28 @@ +using System; +using System.Linq; + +namespace DevTips.Tips; + +class DelegateClient +{ + public static void Client() + { + int[] arr = { -10, 20, -30, 4, -5 }; + + System.Console.WriteLine("Find"); + int pos = Array.Find(arr, IsPositive); + System.Console.WriteLine(pos); + + System.Console.WriteLine("n >= 0"); + var v = arr.Where(n => n >= 0); + foreach (var elem in v) + { + System.Console.WriteLine(elem); + } + } + + private static bool IsPositive(int i) + { + return i >= 0; + } +} \ No newline at end of file