Cannot implicitly convert string[] to string when splitting

前端 未结 3 2059
悲哀的现实
悲哀的现实 2020-12-21 20:25

I am new to c# and I don\'t understand why this isn\'t working. I want to split a previously splitted string.

My code is the following:

int i;
string         


        
3条回答
  •  太阳男子
    2020-12-21 21:26

    As others have said, Split returns an array. However, you can split on more than one character at a time. For example,

    string s = "a,b,c,d-d";
    var split = s.Split(new[] {',', '-'});
    

    In this case, the split array would contain 5 indices, containing "a", "b", "c", "d", and "d".

提交回复
热议问题