Usage Of Ref and Out Parameters

Satyadevanand
Posted by Satyadevanand under C# category on | Points: 40 | Views : 930
Modifiers for parameters
Ref and Out

class RefOutParams
{

void Withtax(ref decimal amt)
{
amt = amt + (amt * 12.4M / 100);
}

void TaxValue(out decimal tax)
{
tax = 12.4M;
}
static void Main(string[] args)
{
RefOutParams p = new RefOutParams();
decimal amount=50;

p.Withtax(ref amount);
Console.WriteLine(amount);

decimal tax;
p.TaxValue(out tax);
Console.WriteLine(tax);

}

Comments or Responses

Login to post response