Explain how methods are useful in Programming in General. Provide Examples.
Example:
using System;
class HelloWorld {
static void Main() {
Console.WriteLine(sum(10,2));
Console.WriteLine(sum(10,4));
Console.WriteLine(sum(100,212));
}
static int sum(int a,int b){
return a+b;
}
}
In the above code I have created a sum method and using it 3 times in main method
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
Please Like and Support me as it helps me a lot
Get Answers For Free
Most questions answered within 1 hours.