Hi,

how to declare optional parameters in C#. Like...
public void test(int a, Optional int b)
Thanks in advance.

LizR is right. More simply put you can define a single method like this:

public void test(int a){...}
public void test(int a, int b){...}

At run time you can call test with whichever set of parameters you want.

I disagree on LizR. we can an optional parameter.

try this...

private void Form1_Load(object sender, EventArgs e)
{
       sample("Hello World.");
}

private void sample(string str, params object[] mode)
{
            MessageBox.Show(str);
}

hope this would help.

regards.

Not in the way the OP implied eg the equivelent of void myfunc(int param1=0, string param2="default") like a lot of languages support.