What is wrong with my dictionary?

what am I doing wrong here? I need to create a dictionary of String, String…but its not working.

I get this same error with everything except for Dictionary<Object,Object> but I need to have the Value as an array of string. This is what my initialization looks like:
new Dictionary<string,string>{}
and tried
new Dictionary<String,String>{}
new Dictionary<System.String,System.String>{}
new Dictionary<string,string()>{}
It seems to be getting it confused with IDictionary, but I tried IDictionary and it doesn’t work either
I’m new to c# and uipath I appreciate your help so much

You created your dictionary as (of string, string) but the Add to dictionary activity requires it to be (of string, object)

Note that since the value is object, it can contain anything - a string, int, datetime, list, array, datatable, etc.

You could avoid all this by not using Add to dictionary. Just use Assign:

Assign dict(region) = arrCountry

Then having your dict defined as (of string, string) will work fine.

1 Like

you had defined a dictionary of string, string (string array)

It looks like there is a mismatch set on the typergument from the Add to Dictrionary. Can you check and maybe share a screenshot with us? thanks


find starter help here:
DemoDictionary.xaml (7.2 KB)

1 Like

So the simple assign was actually perfect for me, but this is actually what is stored in my add to dictionary activity:

but where I initialize the variables its all dictionary. It just defaults to IDictionary or something

I’m thinking since I downloaded your project, that it might have something to do with a compatibility issue with my version of UiPath and Microsoft.Activities.Extension because none of your activities work?

Adding entries with the assign we do practice and is compact

  • ensure that Dictionary is used as Datatype not IDictionary (the I<-)
  • do not use the datatype Object for a key

nevermind I got it when I pasted it into the project

ok so your add to dictionary activity works from your project when I paste it in with the exact same string and array, but mine does not work. Strange

Where is the setting to change this? This is the only thing that is different

i flipped our dictionaries around to show you that its not the dictionary its the activity and i just dont know where to switch this here:

Your Properties:

My Properties:

can you share your XAML?

Make sure you’re selecting the one under System.Collections.Generic:

It is about the Activity and that the typeargument from initial wizard cannot be changed (official, hackings workaround on xaml we do not elaborate on it so far)

just go for the compact syntax within an assign, and it will work

1 Like

thank you so much to both of you

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