tmighty tmighty - 2 months ago 10
Vb.net Question

System.Object[] can't be converted to System.String[]

I'm trying to convert the C# line

string[] phrases = text.Split (new[] { '\"' }, StringSplitOptions.RemoveEmptyEntries);


to VB.NET.

My attempt was

Dim phrases() As String = text.Split (New Object() { """"c }, StringSplitOptions.RemoveEmptyEntries)


However, I'm getting the error "System.Object[] can't be converted to System.String[]".

What I'm doing wrong, please?

Answer

You can use any online C# to VB converter and you'll get this:

Dim phrases As String() = text.Split(New String() {""""C}, StringSplitOptions.RemoveEmptyEntries)

So the wrong part was using Object().