Split string requires array declaration

前端 未结 2 939
孤独总比滥情好
孤独总比滥情好 2021-01-29 13:06

string myStr = \"part1#part2\";

To split this simple string Split() method expect array with arguments to be passed. Really? Why I can\'t just specify

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 13:13

    You can. String.Split takes a param argument, which allows for variable number of arguments.

    The following works as expected

    var text = "a,a,a";
    var parts = text.Split(',');
    

提交回复
热议问题