Here's what I get in VB6 Description:
How to do this in c#?
P.S. I also don't know how to use optional parameter in c#.
As far as I'm aware, there's no exact equivalent.
public void DoSomething(SomeClass A = null)
{
}
There is no difference in C# between the following:
DoSomething(null);
DoSomething();
The closest you'll get is a null check on A
. For value types, you can check the default (Though VB6 IsMissing
does not support 'simple data types').
That is, the translated version of:
Sub DoSomething(Optional A As SomeClass)
If IsMissing(A) Then
'Missing
Else
'Not missing
End Sub
Is:
public void DoSomething(SomeClass A = null)
{
if (A == null)
{
//Missing
} else {
//Not missing
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With