Search Results

Search found 1 results on 1 pages for 'user1004039'.

Page 1/1 | 1 

  • C# SortedList, getting value by key

    - by user1004039
    I have SortedList in descending order. public class MyComparer : IComparer<int> { public int Compare(int x, int y) { if (x.CompareTo(y) > 0) return -1; return 1; } } class Program { static void Main(string[] args) { SortedList<int, bool> myList = new SortedList<int, bool>(new MyComparer()); myList.Add(10, true); bool check = myList[10];//In this place an exception "Can't find key" occurs } } When SortedList created without my own IComparer the code works fine and no exception occurs.

    Read the article

1