[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

insert a keyvaluePair in middle of dictionnary ?

Posted on 2013-01-23
3
Medium Priority
?
386 Views
Last Modified: 2013-01-23
Hello EE,
I have a dictionnary of integer, string


lets say :

1 , Earth
2, Hi
3, Hello Mona Lisa
4, Moon


lets say I do :

for each kvp as KeyValuePair(Of Integer, String) in dict
  if kvp.Value.Contains("Hello") then
         ---> here is my problem:   insert new KVP AFTER index 3 and put : 4, Hello Peter
  end if
next

so then 4,Moon would now be 5,Moon and so forth


is that possible ??
0
Comment
Question by:PhilippeRenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Assisted Solution

by:mcmahon_s
mcmahon_s earned 1000 total points
ID: 38811883
Not without renumbering everything after the value you are trying to insert (i.e. removing and reinserting with a new key). But..... if this is really what you need then that more than likely means you have a poor implementation choice because your key once assigned should not change.

What is the purpose of what you are trying to do?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 total points
ID: 38811940
Agreed. Why not use a List(Of String) and use the implicit numbering you get with the index of the particular item (offsetting for zero, of course!)?
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 38811976
you're right. I should not use Dictionnary for my purpose.
list might be easier.

i was thinking that right afgter I press "submit your question" .. :P
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

649 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