How to initialize a dictionary in UI Path?

I have a long dictionary of multiple config elements like this:

{

“sheetID”: “efretbryygdf23r4ty54htrbgfdv”,
“sheetName”: “testSheet”

}

I have declared a dictionary variable and I want to initialize that dictionary with the one as I shared above, I tried to use:

new Dictionary<string, string>() { [“key1”] = “value1”, [“key2”] = “value2” }

but it gives me an error saying expected end of line. Does anyone know the way to initialize the dictionary like this?

3 Likes

Hi @spidey

Use this to intialise dictionary

dict= New Dictionary (Of String, String)

Check this too

Regards

Nived N :robot:

Happy Automation :smiling_face::smiling_face::smiling_face:

Hi do you mean:
New Dictionary(Of String, String)
{
{“sheetID”, “efretbryygdf23r4ty54htrbgfdv”},
{“sheetName”, “testSheet”}
}

New Dictionary(Of String, String) From
{
{“sheetID”, “efretbryygdf23r4ty54htrbgfdv”},
{“sheetName”, “testSheet”}
}

Use this

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

7 Likes

Thank you very much Nived_Nambiar!

1 Like

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