split分割后,怎么取到分割后的值 operList[] = {"mst002_view","mst002_Save","mst001_Editor"........};
for (int i = 0; i < operList.Count; i++)
{
var competenceId = operList[i];
competenceId.Split('_');
}
分割后就是成了 mst002 和 view
mst002 和 Save
mst001 和 Editor
.......
我怎样才能拿到前半个值和后半个值呢 ------最佳解决方案-------------------- var operList = new string[] { "mst002_view", "mst002_Save", "mst001_Editor" };
var ary1 = operList.Select(t => t.Split('_')[0]).ToArray();
var ary2 = operList.Select(t => t.Split('_').Length > 1 ? t.Split('_')[1] : "").ToArray();
------其他解决方案-------------------- operList[] = {"mst002_view","mst002_Save","mst001_Editor"........};
for (int i = 0; i < operList.Count; i++)
{
var competenceId = operList[i];
string [] cp = competenceId.Split('_');