查找和数组在C#中删除项目 [英] Find and remove items from array in c#
本文介绍了查找和数组在C#中删除项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串数组。我需要从数组中删除某些项目。但我不知道需要删除的项目的索引。
我的阵列是:串[] ARR = {,一个,B,,C,,D,,E,F, ,}。
我需要删除,项目。删除之后,即我的结果应该是
ARR = {A,B,C,D,E,F}
我怎么能这样做呢?
解决方案
的String [] ARR = {,A,B,,C, ,D,,E,F,,};
ARR = arr.Where(S =>!S =).ToArray();
I have a string array. I need to remove some items from that array. but I don't know the index of the items that need removing.
My array is : string[] arr= {" ","a","b"," ","c"," ","d"," ","e","f"," "," "}.
I need to remove the " " items. ie after removing " " my result should be arr={"a","b","c","d","e","f"}
how can I do this?
解决方案
string[] arr = {" ", "a", "b", " ", "c", " ", "d", " ", "e", "f", " ", " "};
arr = arr.Where(s => s != " ").ToArray();
这篇关于查找和数组在C#中删除项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文