473,585 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a SortedList that allows Duplicate Keys?

Anyone know how to create a sorted list with duplicate keys? The sorted
list dies when you try and insert a duplicate key.

Nov 21 '05 #1
2 14130
Hi Gregory

Duplicate keys are not supported by sorted list. It is fairly straightforward to create your own
sorted list though by implementing the IComparable or IComparer interfaces.

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...classtopic.asp

Richard
Nov 21 '05 #2
Thanks!

I will have to hunt around for a more meaty example on this topic. Looks
like this is a good place to start.
"Richard Myers" <fa**@address.c om> wrote in message
news:uv******** ******@TK2MSFTN GP15.phx.gbl...
Hi Gregory

Duplicate keys are not supported by sorted list. It is fairly
straightforward to create your own
sorted list though by implementing the IComparable or IComparer
interfaces.

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...classtopic.asp

Richard

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2757
by: Zeng | last post by:
Would someone know why SortedList doesn't work for these two keys? System.Collections.SortedList.Add(Object key, Object value) +221 My code looks something like below, the Guid.NewGuid().ToString() is appended to make sure the key is unique in case of duplicated data.
1
1531
by: Vai2000 | last post by:
Hi All, Is there a way to custom sort the SortedList by its value...I know how to do with keys by passing a special Comparable Class...but how do I sort it based on Values? TIA
3
4548
by: studen77 | last post by:
I'm not comprehending how C# assigns indexes to items you add to a SortedList item. Here's some example code: sl.Add ("first_item","First Item"); sl.Add ("second_item", "Second Item"); sl.Add ("third_item","third item"); sl.Add ("fourth_item","fourth item"); I then run a FOR loop to print out the index for each item in the SortedList, and...
1
7758
by: rgarf | last post by:
I want to be able to change the values in a SortedList, I tried doing a foreach but it doesn't let me modify the DictionaryEntry. So How do I go about changing the values of a SortedList as I loop through it? Thanks
2
3076
by: Pekka | last post by:
Could somebody say why the piece of code below does not work? My purpose is to renumber keys in a SortedList (after removal of an item) so that the keys would always contain an unbroken sequence of integers starting with 1. For some reason this is not the result. IDictionaryEnumerator dictEnum = sortedList.GetEnumerator(); int i=1; while...
0
970
by: andreas | last post by:
Hi, I have filled a sortedlist with items of instances of a class and the corresponding keys Now i will have back all the keys and the corresponding properties of the items dim keyitem as string dim slist as new sortedlist dim cl as new clss cl.name = "Robert"
4
6761
by: semedao | last post by:
Hi, I want to implement list of key-values that can be sort by 2 ways. let's say that in the first step I wanted to make SortList based on Key = int index that cannot change and Value is another SortedList like this: class OtherSortedList : SortedList { ..... int GetTotalAmountOfAllItems().... }
1
3896
by: raylopez99 | last post by:
I seem to get name collision between the Generic collection SortedList and C++.NET Framework collection SortedList. How to resolve? Here are the libraries that seem to clash: System::Collections::SortedList, System::Collections::Generic::SortedList, using namespace System::Collections; using namespace System::Collections::Generic; ...
5
6285
by: ShaneO | last post by:
VB.NET 2005: I need to sort an array of Customer details based on transaction dates. If I use a SortedList the obvious problem is that it does not support duplicate keys. Does anyone have a suggestion (or routine) to achieve this type of date sort? Thanks in advance for your assistance.
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.