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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.