parent
1e61c77fff
commit
8ce6c223d1
@ -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; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue