|
C#
does not allow optional parameters. Overloaded methods are the
alternative in C# to optional parameters (these are inserted into
the converted code by Instant C#). A VB method with n
optional parameters is converted to n + 1 overloaded
methods. The overloaded methods call the overloaded method with the
maximum number of parameters (which contains your original method
code), passing the default values originally specified for the
original optional parameters.
Here's an example of the simplest possible case:
VB:
Public Sub TestOptional(Optional ByVal x As Integer = 0)
...
End Sub
C#:
public void TestOptional()
{
TestOptional(0);
}
public void TestOptional(int x)
{
...
}
If you need to convert between VB.NET and C#
and you are depending on the results being reliable and accurate,
then you will want to have
Instant
C#,
the best VB.NET to C# converter, or
Instant
VB,
the best C# to VB.NET converter, at your fingertips.
|