Default value for parameters

  • Thread starter Thread starter S K
  • Start date Start date
S

S K

Is it possible to give default values for parameters ?

like void func(int x, int y = 0);

Thanks
 
Not in C#. You will have to use method overloading. Such as:

void func(int x)
{
func(x,0)
}

void func(int x, int y)
{
....
}
 

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

Back
Top