- Basically , a Method is a piece of code used for the re-usability purpose.
- Method is of 2 types Function and Procedure
- Function is a method which returns a value to the calling place
Procedure is a method which returns nothing to the calling place.
Procedure syntax:
<procedurename>(<params>[optional])
{
//code
}
Procedure samples:
Display()
{
Console.WriteLine("Procedure returns no value");
}
Add(int a, int b)
{
Console.WriteLine("Sum : "+(a+b));
}
Hence, a function always returns a value or void to the calling place and a procedure returns nothing.
C# do not support Procedure. So functions in C# should be defined with the return type.