Well, I have a function that takes a string array as input...
I have a string to process from that function...
So,
Dim str As String = "this is a string"
func(// How to pass str ?)
Public Function func(ByVal arr() As String)
// Processes the array here
End Function
I have also tried:
func(str.ToArray) // Gives error since it converts str to char array instead of String array.
How can I fix this?
With VB10, you can simply do this:
func({str})
With an older version you'll have to do:
func(New String() {str})
Just instantiate a new array including only your string
Sub Main()
Dim s As String = "hello world"
Print(New String() {s})
End Sub
Sub Print(strings() As String)
For Each s In strings
Console.WriteLine(s)
Next
End Sub
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