Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
_comboBoxItems 是数组
[0] = "01 01010304" [1] = "01 01230304" [2] = "01 01010784" [3] = "01 01135404"
如果存在,我可以用 linq 删除空白空间之前的所有内容吗?
[0] = "01010304" [1] = "01230304" [2] = "01010784" [3] = "01135404"
或者我必须使用 foreach 然后删除数据并将其添加回数组。
如果需要数组,请尝试_comboBoxItems.Select(s => s.Split(' ').Last())以 a结尾。.ToArray()
_comboBoxItems.Select(s => s.Split(' ').Last())
.ToArray()
采用
mycombobox.Items = mycombobox.Items.Select(x => x.Split(' ')[1]).ToArray();