+ 1
Can anyone explain this bit of code? I don't really get the expression assigned to x.
I think the method assigns 14 if it finds it in the array otherwise returns 0. But I ain't sure if I'm correct. static void Main(string[] args) { int[] arr = {10,15,16 }; var x = arr.FirstOrDefault(z => z.Equals(14)); Console.WriteLine(x + 15); }
2 Réponses
+ 5
https://www.dotnetperls.com/firstordefault
Read this site.
0
Thanks! I usually stop at Microsoft docs but sometimes it's quite confusing to understand what they explain.