Skip to main content

C# Lambdas

Here are quick examples of how to create anonymous lambdas in c# method blocks.

 

This lambda accepts an int, and returns a composite (int and string):

Func<string, (int res, string? data)> krcb = (k) =>
{
    return (1, null);
};

This lambda accepts a string, with no return (action vs func):

Action<string> testaction = (k) =>
{
  // Do stuff...
};