How to break a string at each comma?

前端 未结 6 1879
再見小時候
再見小時候 2021-01-24 15:11

Hi guys I have a problem at hand that I can\'t seem to figure out, I have a string (C#) which looks like this:

string tags = \"cars, motor, whee         


        
6条回答
  •  感情败类
    2021-01-24 15:59

    make use of Split function will do your task...

    string[] s = tags.Split(',');
    

    or

    String.Split Method (Char[], StringSplitOptions)

    char[] charSeparators = new char[] {',',' '};
    string[] words = tags.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
    

提交回复
热议问题