public static void Main()
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var evenNumbersStatementLambda =
return numFromNumbers % 2 == 0;
Console.WriteLine($"evenNumbersStatementLambda: {string.Join(",",evenNumbersStatementLambda)}");
var evenNumbersExpressionLambda = numbers.Where(
Console.WriteLine($"evenNumbersExpressionLambda: {string.Join(",",evenNumbersExpressionLambda)}");
string firstName = "Alan";
BuildQuery(fieldToSearch, firstName),
Console.WriteLine(runQuery1);
string lastname = "Adams";
$"SEARCH {fieldToSearch}:{lastname}",
Console.WriteLine(runQuery2);
string RunQuery(Func<string, string> func, string fieldToSearch)
return $"Running a query - {func(fieldToSearch)}";
string BuildQuery(string fieldToSearch, string valueToSearchFor)
return $"SEARCH {fieldToSearch}:{valueToSearchFor}";
ShallowAndDeepMethods shallowAndDeepMethods = new ShallowAndDeepMethods();
var resultFromShallowAndDeepMethods = shallowAndDeepMethods.Shallow(
$"Example 5. Result of a * b ({a} * {b}) is {a * b}",
Console.WriteLine(resultFromShallowAndDeepMethods);
OtherMethods otherMethods = new OtherMethods();
var resultFromOtherMethods = otherMethods.Top(
$"Example 6. Result of a + b ({a} + {b}) is {a + b}",
Console.WriteLine(resultFromOtherMethods);
public class OtherMethods
public string Top(Func<int, int, string> func, int num1)
=> Botton((x, y) => func(x, y), num1);
public string Botton(Func<int, int, string> func, int num1)
return func(num1, localNumber);
public class ShallowAndDeepMethods
public string Shallow(Func<int, int, string> shallowFunc, int num1, int num2)
num1, num2, default(int));
public string Deep(Func<string, int, int, string> deepFunc, int num1, int num2, int num3)
return $"In Deep: calling func with {num1}, {num2} - {deepFunc("this text will not be used", num1, num2)}";