cannot convert from 'string' to 'char[]' for split

前端 未结 7 1848

I am using the following code to split a string:

string sss=\"125asdasdlkmlkdfknkldj125kdjfngdkjfndkg125ksndkfjdks125\";

List s = new List<         


        
7条回答
  •  庸人自扰
    2020-12-11 01:22

    That depends on what you wish to achieve. If you wish to split at the string "125" then do

    sss.split(new[]{"125"},StringSplitOptions.RemoveEmptyEntries); //or StringSplitOptions.None
    

    if you wish to split at any occurrence of 1, 2 or 5 then do

    sss.split(new[]{'1','2','5'}); 
    

提交回复
热议问题