//list类型 去掉list中的重复数据
VmProjectTypeData = VmProjectTypeData.Where((x, i) => VmProjectTypeData.FindIndex(z => z.PTypeID == x.PTypeID) == i).ToList();

C#数组如何去掉数组中的空元素
string[] list = { "a", "b", "", "d", "e", "f" };
string[] newlist = list.Select(s=>s).Where(s => !string.IsNullOrEmpty(s)).ToArray();

或是换另一种linq的写法:
string[] list = { "a", "b", "", "d", "e", "f" };
string[] newlist = (from s in list where !string.IsNullOrEmpty(s) select s).ToArray(); 
posted on 2018-06-01 10:23  紫嫣凝语  阅读(105)  评论(0)    收藏  举报