Split String in VB.net

后端 未结 2 394
独厮守ぢ
独厮守ぢ 2021-01-24 07:29

How do I split a string \"99 Stack Overflow\" into 2 in vb.net

I want the first value to be 99 and the 2nd to be Stack Overflow.

Please help

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-24 08:00

    This should do it:

    result = yourstring.Split(new Char() { " "c}, 2)
    

    More here. (I think that's how you write a literal Char array in VB.Net; I'm not much of a VB.Net guy, most of what I do in .Net is in C#.

    If I'm wrong about how you right literal char arrays and you can't figure it out, you can use a version of it that takes a String instead:

    result = yourstring.Split(" ", 2, StringSplitOptions.None)
    

    Details on that one here.

提交回复
热议问题