Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert Item In Dictionary
Message
De
04/05/2010 09:04:09
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
03/05/2010 17:04:35
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01462835
Message ID:
01462997
Vues:
57
>>>>>>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...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform