Return statement in c#

Return statement in c#

 

This return statement is used to terminate any execution flow in any method. It returns control to the calling method. The value returned by it is optional, and when the return type is void.

 

using System; 
class usingcsharp
{ 
static int Add(int a) 
{
    int b = a + a; 
    return b; 
} 
static public void Main() 
{ 
    int num = 10; 
    int result = Add(num); 
    Console.WriteLine(" Addition is: {0} : ", result); 
} 
}

2021-10-03