Set the default value for the optional "List (Of t)" to an empty list?
1 answer
You can not. Optional values ββmust be compile-time constants. The only compile-time constant you can assign List(Of T)
is Nothing
.
What you can do is overload this method for those who don't have a parameter List(Of T)
. This overload can then pass empty to the List(Of T)
original method:
Sub abcd(a as something, b as something)
abcd(a, b, New List(Of T)())
End Sub
Sub abcd(a as something, b as something, c as list(of thing))
doStuff()
End Sub
+5
source to share