doubt

  • Thread starter Thread starter Baskar RajaSekharan
  • Start date Start date
B

Baskar RajaSekharan

Hi,

Please let me know is ther any way to pass some default parameters to a
Method in C-Sharp without overloading the Method.
In VB we can done the above with the help of optional parameter . What's
the Equvelent in C-Sharp.

Regards,
R.Baskar
 
In C# you overload. in which case it can simply be done like this

private int Calculate(int number1, int number2)
{
return Calculate(number1, number2, 100);
}

private int Calculate(int number1, int number2, int number3)
{
return number1 + number2 + number3;
}

Probably for safety reasons as forgetting a parameter is easier to spot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Doubt 5
clarification is needed 4
Doubt 1
Doubt 4
doubt 1
How to Erase a FileContent in c -Sarp? 7
Doubt in C-Sharp 1
Line No 10

Back
Top