I was trying to put together a solution to: Insert spaces between words on a camel-cased token
Essentially, he wants to turn 'ThisIsATest' into 'This Is A Test'. I thought, 'Oh, that's easy, I can do it with LINQ' but I struggled with it.
Can someone help me?
Dim s As String = String.Join("", From myChar As Char In myStr _
Select If(Char.IsUpper(myChar), (" " & myChar).ToString, myChar.ToString))
Is the path I started to go down, but I'm having trouble getting the results into something I can work with. I even added the .ToString to try and get back an array of Strings, but I'm still getting an error.
Unable to cast object of type 'WhereSelectEnumerableIterator`2[System.Char,System.String]' to type 'System.String[]'.
I believe that means I'm getting a collection of System.Char, System.String instead of just a System.String like I want.
What am I doing wrong?