Expand|Select|Wrap|Line Numbers
- Product prod = new Product();
- prod.Components = new sortedList( new IntComparer() );
- prod.Components.Add(0,1);
- prod.Components.Add(1,2);
- private class IntComparer : Comparer <int>
- {
- public override int Compare(int x, int y)
- {
- if (x < y)
- return 0;
- else if (x == y)
- return 0;
- else return -1;
- }
- }
Item has already been added. Key in dictionary: "0" Key being added: "1".
Since 0 and 1 are different key, why this error occur?
In fact these codes had run correctly several days before, may be there are something error elsewhere ?