Reputation: 8564
Is there a way to have default function parameters in C# like we have in C++??
eg:
foo(int i = 10, int j = 20) {}
Upvotes: 1
Views: 364
Reputation: 4260
if you don't have C# 4 you can define your method twice, like this:
public int MySillyMethod(int a)
{
return MySillyMethod(a, 1);
}
public int MySillyMethod(int a, int b)
{
return a*b;
}
Upvotes: 0