开发者

.Split("//") is also picking up "/"

I am delimiting my data with the "//" as I am pass开发者_如何转开发ing it up to my webservice. My webservice is splitting the data into an array like so:

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

Everything works great, however, if I pass in some data like this: 100/100 then that also gets split. Is there a way to make sure that only the "//" gets split?


The VB.Net compiler is converting your string into a Char array and calling this overload.
Thus, it's splitting on either / or /.

You need to call the overload that takes a string array, like this:

"100/100".Split(New String() { "//" }, StringSplitOptions.None)


Always, always use Option Strict.

With Option Strict the original code produces an error, rather than choosing the unhelpful overload:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜