我正在尝试使用 LINQ,但我不断收到此错误消息:
运算符“<”不能应用于“Ilistprac.Location”和“int”类型的操作数
我尝试了覆盖,但收到一条错误消息:
'Ilistprac.Location.ToInt()':找不到合适的方法来覆盖
所有的 IList 接口也是用 IEnurmerable 实现的(除非有人希望我在此列出)。
class IList2
{
static void Main(string[] args)
{
Locations test = new Locations();
Location loc = new Location();
test.Add2(5);
test.Add2(6);
test.Add2(1);
var lownumes = from n in test where (n < 2) select n;
}
}
public class Location
{
public Location()
{
}
private int _testnumber = 0;
public int testNumber
{
get { return _testnumber; }
set { _testnumber = value;}
}
public class Locations : IList<Location>
{
List<Location> _locs = new List<Location>();
public Locations() { }
public void Add2(int number)
{
Location loc2 = new Location();
loc2.testNumber = number;
_locs.Add(loc2);
}
}