c# lambda expression
int[] numbers = {1, 3, 5, 6, 7, 8};
//----------------------------------------------------------//
//Original expression
public static bool IsEven(int num)
{
return num % 2 == 0;
}
bool hasEvenNumber = Array.Exists(numbers,
IsEven);
//----------------------------------------------------------//
//Lambda expression
bool hasEvenNumber = Array.Exists(numbers,
(int num) => num % 2 == 0 );
//Some code can be removed:
// - The modulo operator (%) is only used with numbers*/
bool hasEvenNumber = Array.Exists(numbers,
(num) => num % 2 == 0 );
// - just one parameter, we don’t need the parentheses
bool hasEvenNumbers = Array.Exists(numbers,
num => num % 2 == 0 );
//----------------------------------------------------------//
Also in C#:
- c# sql duplicate key exception
- unity set list of strings
- c# trim string
- how to flip selection in aseprite
- validating file upload asp.net core mvc
- prefab gets character transform
- disable mouse unity
- how to reference scripts in other scenes unity
- or symbol in unity
- multidimensional meaning
- array copy c#
- how to declare variables in c#
- page refresh on button click in c#
- what data type should be for contact number in asp.net
- c# loop through object
- string format comma c#
- unity vector3 to array
- write last line txt file c#
- how to change scenes in unity
- fly cam extended script unity 3d
- how to update modal class using dbfirst in asp.net core
- unity scene name get
- Microsoft.AspNetCore.Components.Forms.InputSelect`1.TryParseValueFromString(String value, TValue& result, String& validationErrorMessage)
- change navigation bar of master detail page xamarin form