C# program for addition of two numbers using a method
Program.cs
Arithmetic a = new Arithmetic();
Console.Write("Addition: " + a.addition(10, 20));

class Arithmetic
{
    public int addition(int a, int b)
    {
        int sum = a + b;
        return sum;
    }
}
Output
kodingwindow@kw:~/csharp$ dotnet run
Addition: 30
kodingwindow@kw:~/csharp$ 
What Next?
C# Inheritance
Advertisement