How to replace alternate value of Dictionary from the List

Hii all,

I have a dynamic Dictionary(of String,String)
Dict= [abc, 1,23,2,34,3,45…]

I have another dynamic List(String) as List= {“Jan 22”, “Feb 22”, “May 22”…}

I need to change the alternate value of Dictionary like if there’s “1” in Dict then it takes “Jan 22” or if there’s 3 in value of Dict then it should take “May 22” likewise.

So that My final Dictionary should be like this [abc , Jan 22,23,Feb 22,34,May 22,45…]

Please suggest me anything which will be helpful.

Thank You


Can you show the dictionary properly please

which is the key and what is the corresponding value


here A and B are keys and 123 and 345 are values



How about the following?

newDictionary = listStr.Zip(dict.Keys,Function(s1,s2) Tuple.Create(s1,s2)).ToDictionary(Function(t) t.item2,Function(t) t.Item1) (2.5 KB)


Here Key is ‘abc’ and the value is (1,23,2,34,3,45…) in the Dictionary.

Hi @Yoichi ,

The key of dictionary should not be change , only the alternate values should be changed like I explained above.
If the value of Dictionary contains ‘1’ then it must takes ‘Jan 22’ from the below List .
I hope you are now getting my doubt.



Can you try the following?

newDictionary = dict.ToDictionary(Function(kv) kv.key, Function(kv) String.Join(",",kv.value.Split({","c}).Select(Function(s) if(dictFromList.ContainsKey(s),dictFromList(s),s)))) (2.6 KB)


1 Like

Hii @Yoichi ,
This is working in simple condition .

But in my case, I’ve assigned and giving data to Dictionary in one For Each activity and the ’ List ’ ( from which I need to replace the alternate value of Dictionary ) is created in another For Each activity.

So in this case it is not working.
Please tell me some different solution.



Please try like this

  1. Use a for loop on the dict.keys.ToArray() and change for type argument to string
  2. Inside loop use a assign and create variable of type array A1 and A1 = dict(currentitem).ToString.Trim.Split({","},StringSplitOptions.None).ToArray
  3. Inside the loop use one more for loop(currentitem2) with Enumerable.Range(0,A1.Count).ToArray and change type argument to integer
  4. Inside the second loop use if with (currentitem2 mod 2).Equals(0)
  5. On then side use assign A1(currentitem2) = L1(Cint(A1(currentitem2))) (L1 is list containing your dates)
  6. Outside the current loop and inside the fist loop use assign dict(currentitem) = String.Join(",",A1)

Hope this helps


Hii @Anil_G ,

I’ve tried the solution given by you and i’m getting this error .
Please see the attached screenshot


can you please share the code using the solution you mention.


I missed a bracket please try now…and if you face issue show me the code you used


Thanks @Yoichi .
It works.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.