Reputation: 5968
Is it possible to have a default value for a function parameter of type Class ?
Something like this
public sub MyMethod(A as integer, optional B as integer = 0, optional Control as Control = new TextEdit)
End Sub
I tried this but it gives an error : a constant expression is required
Any ideas please ?
Thanks.
Upvotes: 0
Views: 33
Reputation: 1062820
Optional values must be viable literals. In the case of reference-types (except for string
, which has different rules), this means: null
(Nothing
), or (identically) default(TheType)
(whatever that is in VB). That's all.
Upvotes: 1