Can I give a default value to parameters or optional parameters in C# functions?

后端 未结 6 694
花落未央
花落未央 2020-12-03 09:46

Can I give default parameters in C#?

In C:

void fun(int i = 1)
{
    printf(\"%d\", i);
}

Can we give parameters a default value? I

6条回答
  •  孤城傲影
    2020-12-03 09:57

    Yes, but you'll need to be using .NET 3.5 and C# 4.0 to get this functionality.

    This MSDN page has more information.

提交回复
热议问题