.Split ("//") also matches "/"

I am sharing my data with "//" as I pass it to my web service. My web service breaks the data into an array as follows:

myArray = al(i).ToString.Split("//") 

Everything works fine, however, if I pass a few such data: 100/100, then this will also be shared. Is there any way to make sure that only "//" gets split?

+6
source share
2 answers

The VB.Net compiler converts your string into a Char array and causes this overload .
Thus, it is divided into / or / .

You need to call overload, which takes an array of string , for example:

 "100/100".Split(New String() { "//" }, StringSplitOptions.None) 
+20
source share

Always, always use Option Strict .

With Option Strict source code generates an error rather than selecting a useless overload:

Error 1 Option Strict Inhibit implicit conversions from 'String' to Char.

+2
source share

All Articles