Answers for "pass params in c#"

C#
3

c# pass method as parameter

public int Method1(string input)
    {
        return 0;
    }
	
    public bool RunTheMethod(Func<string, int> myMethodName)
    {
        int i = myMethodName("My String");
        return true;
    }

    public bool Test()
    {
        return RunTheMethod(Method1);
    }
Posted by: Guest on May-24-2021
0

C# params

public static void UseParams(params int[] list)
    {
        for (int i = 0; i < list.Length; i++)
        {
            Console.Write(list[i] + " ");
        }
        Console.WriteLine();
    }

    public static void UseParams2(params object[] list)
    {
        for (int i = 0; i < list.Length; i++)
        {
            Console.Write(list[i] + " ");
        }
        Console.WriteLine();
    }
Posted by: Guest on August-27-2021

C# Answers by Framework

Browse Popular Code Answers by Language