Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple way to sort a collection class

Posted on 2011-09-21
2
Medium Priority
?
294 Views
Last Modified: 2012-05-12
I have a collection of countries, called CountryCollection, defined thus:

public class CountryCollection : KeyedCollection<string, Country>

A country has a CountryName and CountryCode, among other things.

What is the best/easiest way to sort the collection by CountryName in C# ?
0
Comment
Question by:purplesoup
2 Comments
 
LVL 9

Accepted Solution

by:
xav056 earned 1000 total points
ID: 36574083
Use a cortedDictionary collection
http://msdn.microsoft.com/en-us/library/f7fta44c.aspx
0
 
LVL 5

Assisted Solution

by:Eduardo Goicovich
Eduardo Goicovich earned 1000 total points
ID: 36574108
basically involves sorting the underlying List of the collection

example here

http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/56adc0f9-aa1b-4acf-8546-082bb01058f2/
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

971 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