我需要选择或删除列表中的数字(0-24)
if (numberList.Contains(int.Parse(c[0])))
{
numberList.Remove(int.Parse(c[0]));
}
if (int.Parse(c[1] + (a.Info[i].Dydis / a.Greitis)) >= 60)
{
int v = int.Parse(c[0]) + 1;
if (numberList.Contains(v))
numberList.Remove(v);
}
if ((rez(a.Info[i].Dydis, a.Greitis)) > 1)
{
numberList.Add(99);
}
}
if (numberList.Count != 0)
{
Ats k = new Ats(a.Vardas, a.Data, numberList);
nera.Add(k);
}
我正在尝试这样的事情,但它不起作用:
for (int i = 0; i < a.LCount; i++)
{
string[] c = a.Info[i].Laikas.Split(':');
var q = from d in numberList
where (numberList.Contains(int.Parse(c[0])))
select new
{
Number = int.Parse(c[0]),
};
我怎么能把这个东西转换成LINQ?
答案 0 :(得分:0)
试试这个:
var exc = c.Select(int.Parse);
var q = numberList.Where(_ => !exc.Contains(_)).ToList();
答案 1 :(得分:0)
使用lambda表达式之类的东西:
numberList.RemoveAll( item => exlist.Contains(item));
exlist 将包含0-24个整数。或者,
numberList.RemoveAll(item => item >= 0 && item <= 24);