C# Custom Methods with Multiple Parameters Example

C#C# custom methods with multiple parameters are very helpful.  You can pass different kind of data type variables to get the desired output.   A custom method in C# can have parameters in the form of integer, string, float, custom class, custom structure, custom interface etc.  The C# custom methods with multiple parameters example is given below, where we are passing  a string as well as integer data type to call our custom method.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
using System;
namespace comments
{
class Program
{
static void Main(string[] args)
{
string total = "The total is ";
int count = 10;
PrintMessage(total, count);
}
public static void PrintMessage(string total, int count)
{
Console.WriteLine(total + count);
}
}
}
using System; namespace comments { class Program { static void Main(string[] args) { string total = "The total is "; int count = 10; PrintMessage(total, count); } public static void PrintMessage(string total, int count) { Console.WriteLine(total + count); } } }
using System;

namespace comments
{
    class Program
    {
        static void Main(string[] args)
        {
            string total = "The total is ";
            int count = 10;

            PrintMessage(total, count);
        }

        public static void PrintMessage(string total, int count)
        {
            Console.WriteLine(total + count);
        }
    }
}

 Output:

The total is 10
Press any key to continue . . .