Solved

Simple way to sort a collection class

Posted on 2011-09-21
2
239 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 250 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 250 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

713 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