CompareTo 不适合我。
我的 linq 查询是
var result = from c in customers
where c.CustomerID.CompareTo(txtSerchId.Text) >= 0
select` c;
并且他们得到了一个例外
//////例外///////////
System.ArgumentException was caught
Message=Value does not fall within the expected range.
我的代码是这样的
var result =
from c in customers
where c.CustomerID.CompareTo(txtSerchId.Text) >= 0
select c;
if (result != null)
{
IEnumerator<Customer> resultEnum = result.GetEnumerator();
while (resultEnum.MoveNext())
{
Customer c = (Customer)resultEnum.Current;
addToDataSet(Guid.NewGuid().ToString(), c);
}
ShowResult();
}
else
{
MessageBox.Show("No Customer found within criteria");
}
例外在这一行
IEnumerator<Customer> resultEnum = result.GetEnumerator();