//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();
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();
浙公网安备 33010602011771号