For some reason I don't seem to have a file in my head for the most efficient usage of the .Net String.Split method. Especially the inline declaration of the array of separators always fails. So, when I found out today I decided to note it here. For myself and everyone else:
For more than one separator:
VB: Dim SplittedStrings() As String = InputString.Split(New [Char](){";"c, ","c})
C#: String[] SplittedStrings = InputString.Split(new Char[]{';', ','});
For just one separator:
VB: Dim SplittedStrings() As String = InputString.Split(";"c)
C#: String[] SplittedStrings = InputString.Split(';');
Geen opmerkingen:
Een reactie posten