[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DescendingComparer problem in SortedList

Posted on 2009-07-09
2
Medium Priority
?
357 Views
Last Modified: 2012-05-07
The following code is from .NET Framework 2.0 p220
it results in the following 3 errors
1      The type or namespace name 'DescendingComparer' could not be found (are you missing a using directive or an assembly reference?)      C:\Documents and Settings\xxxx\My Documents\Visual Studio 2005\Projects\SortedListDescending220\SortedListDescending220\Program.cs      
2      The best overloaded method match for 'System.Collections.SortedList.SortedList(int)' has some invalid arguments      C:\Documents and Settings\xxxx\My Documents\Visual Studio 2005\Projects\SortedListDescending220\SortedListDescending220\Program.cs
3      Argument '1': cannot convert from 'DescendingComparer' to 'int'      C:\Documents and Settings\xxxx\My Documents\Visual Studio 2005\Projects\SortedListDescending220\SortedListDescending220\Program.cs

using System;
using System.Collections;
using System.Text;
 
namespace SortedListDescending220
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sort = new SortedList(new DescendingComparer());
            sort["First"] = "1st";
            sort["Second"] = "2nd";
            sort["Third"] = "3rd";
            sort["Fourth"] = "4th";
            foreach (DictionaryEntry entry in sort)
            {
                Console.WriteLine("{0} = {1}", entry.Key, entry.Value);
            }
 
        }
    }
}

Open in new window

0
Comment
Question by:AstroGuy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 2000 total points
ID: 24816291
You have to define the DescendingComparer class also, there is no such class in the framework.

As you are using framework 2, you should really consider using the strongly typed class SortedList<TKey, TValue> instead.
0
 

Author Closing Comment

by:AstroGuy
ID: 31601737
You were absolutely correct, the Class was deined earlier in the book.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question