如何从数组中删除空白项?
迭代并将非空白项分配给新数组?
String test = "John, Jane";
//Without using the test.Replace(" ", "");
String[] toList = test.Split(',', ' ', ';');
最佳答案
使用带有 StringSplitOptions
的 string.Split
的重载:
String[] toList = test.Split(new []{',', ' ', ';'}, StringSplitOptions.RemoveEmptyEntries);
关于c# - 你会如何从数组中删除空白条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4798755/