Function Parameter in C#

Prabhukiran345
Posted by Prabhukiran345 under C# category on | Points: 40 | Views : 532
Parameter is the essential part of function. However, it is optional but it makes C# function more dynamic than simple function. There are two type of function parameter in C#, Value type parameter and reference type parameter

EXAMPLE:
using System;

namespace Understanding_Parameter
{
class Program
{
// function with parameter
public static int power(int num1)
{
int result;
result = num1 * num1;
return result;
}

static void Main(string[] args)
{
int pow;
// passing arguement as parameter
pow = Program.power(5);
Console.Write("\nPower = {0}", pow);
Console.ReadLine();
}
}
}


Output:
Power = 25

Comments or Responses

Login to post response