tmighty tmighty - 1 year ago 106 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 Source

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().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download