How to get the Index of second comma in a string

前端 未结 2 750
不知归路
不知归路 2020-12-10 00:20

I have a string in an Array that contains two commas as well as tabs and white spaces. I\'m trying to cut two words in that string, both of them before the commas, I really

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 01:09

    You have to use code like this.

    int index = s.IndexOf(',', s.IndexOf(',') + 1);
    

    You may need to make sure you do not go outside the bounds of the string though. I will leave that part up to you.

提交回复
热议问题