How can I combine two SortedLists?

I have two SortedLists that I want to combine into one. Is there something built into C# that can do this or what is an efficient way to handle this?
bemara57Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kirankumar_gouraCommented:
Let's you have three listboxes listBox1, listBox2 and listBox3.
Now you can combine the two Lists(listBox1 and listBox2) into one SortedList with the following code ...
            listBox3.Sorted = true;
            listBox3.Items.AddRange(listBox1.Items);
            listBox3.Items.AddRange(listBox2.Items);
Note: The items of listBox1 and listBox2 need not to be sorted.
Thanks,
- Kiran G
0
Gautham JanardhanCommented:
as Sorted LIst doesnt contain a AddRange i think u will have to loop thru and add
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kirankumar_gouraCommented:
Hi All,
Apologies. I have mis-understood the question. The code is incorrect.
Thanks Gautham, for correcting me.
- Kiran G
0
Gautham JanardhanCommented:
Anyone who has never made a mistake has never tried anything new.... so dont worry
0
bemara57Author Commented:
Drat that's what I was afraid of.. so this is the only way huh:

        foreach (DictionaryEntry element in tempList2)
            tempList1.Add(element.Key.ToString(), element.Value.ToString());
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.