Answers for "how to send function to function c#"

C#
0

how to send function to function c#

# cCopyusing System;

namespace pass_function_as_parameter
{
    class Program
    {
        static int functionToPass(int x)
        {
            return x + 10;
        }
        static void function(Func<int, int> functionToPass)
        {
            int i = functionToPass(22);
            Console.WriteLine("i = {0}", i);
        }
        static void Main(string[] args)
        {
            function(functionToPass);
        }
    }
}
Posted by: Guest on August-17-2021

C# Answers by Framework

Browse Popular Code Answers by Language