リストから削除するアイテムをnullとして設定し、IComparableメソッドCompareToを介してリストを並べ替えて、nullアイテムが一番上になるようにしています...次に、リストでRemoveRange関数を使用しますが、そうすることができません...なるほど次のコードでは問題ありません:
try
{
foreach (Invoice item in inv)
{
if (item.qty == 0)
{
item.CustomerName = null;
item.qty = 0;
i++;
}
}
inv.Sort();
inv.RemoveRange(0, i);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
#region IComparable<Invoice> Members
public int CompareTo(Invoice other)
{
return this.CustomerName.CompareTo(other.CustomerName);
}
#endregion
inv.RemoveRange(0,i); でエラーが発生します。と言って:配列内の2つの要素を比較できませんでした
なんでそうなの??