Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert Item In Dictionary
Message
From
04/05/2010 09:04:09
John Baird
Coatesville, Pennsylvania, United States
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01462835
Message ID:
01462997
Views:
59
>>>>>>I need to insert an item into a Dictionary at a specific position. Each item in the dictionary object has an Order value that specifies the position the item should be in in the collection.
>>>>>>
>>>>>>Anyone know how to do this?
>>>>>
>>>>>Out of curiosity, why do you care where it is?
>>>>
>>>>
>>>>You can add items to the dictionary in any order you want. When you need to process the items in a given order, use a Linq query to extract them in the order you need.
>
>Why do that when you can use a SortedDictionary in the first place ?
>
>>>
>>>I understand that. But aren't Dictionary items retrieved by key? It seems to me the same as caring where a row is in a database table.
>>
>>I was answering Kevin's question. I agree with you that it defeats the purpose of the Dictionary. A Generic List or an Array allows you to insert records at a specific location.
>
>But, given Kevin's requirement, how would you determine the required index?

index of what?

You would order the linq result by his Order Value... and process them...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform