Hello all,
Im trying to build a function in VB.Net that one of its parameters is optional and to hold an array...
Ex:
Public Function test(Optional ByVal arVar As System.Array)
if i do this i'll get the following error:
Optional parameters must specify a default value.
Thats fine, but if i try adding a value to it, either
Optional ByVal arVar As System.Array="val1"
or
Optional ByVal arVar As System.Array={"val1","val2"}
I get this error:
Value of type 'String' cannot be converted to 'System.Array'.
I understand the error, but how to add a value to an array in a function parameters?
BTW, i tried using this too:
Public Function test(Optional ByVal arVar() As String = "val1")
And got the same error...
I hope i made sense in the thread
Thanks in advance,
Best Regards
Im trying to build a function in VB.Net that one of its parameters is optional and to hold an array...
Ex:
Public Function test(Optional ByVal arVar As System.Array)
if i do this i'll get the following error:
Optional parameters must specify a default value.
Thats fine, but if i try adding a value to it, either
Optional ByVal arVar As System.Array="val1"
or
Optional ByVal arVar As System.Array={"val1","val2"}
I get this error:
Value of type 'String' cannot be converted to 'System.Array'.
I understand the error, but how to add a value to an array in a function parameters?
BTW, i tried using this too:
Public Function test(Optional ByVal arVar() As String = "val1")
And got the same error...
I hope i made sense in the thread
Thanks in advance,
Best Regards