如何从数组中删除任何字符串并仅保留整数
string[] result = col["uncheckedFoods"].Split(',');
我有
[0] = on; // remove this string
[1] = 22;
[2] = 23;
[3] = off; // remove this string
[4] = 24;
I want
[0] = 22;
[1] = 23;
[2] = 24;
我尝试了
var commaSepratedID = string.Join(",", result);
var data = Regex.Replace(commaSepratedID, "[^,0-9]+", string.Empty);
但是在第一个元素之前有一个逗号,有没有更好的方法来删除字符串?