Dictionary..--

Hi, here I was trying to manipulate the dictionary variable to string.Could some help me whay I am getting this error.

@Pushpendra_kowthavarapu

Did you give dict(name).ToString

Cheers

@Pushpendra_kowthavarapu

Put .ToString after the object variable

Still same error. But when I done before it was fine.

The below image is the previous one still working fine.

Hi @Pushpendra_kowthavarapu
In your case, you can use only ‘dict’ in your for, and t


o retrieve de value of key, you can use currentItem.Value. Examine this example

@Pushpendra_kowthavarapu

Can you show the current script that you are using in assign

Also as mentioned above you can directly use dictionary in the for loop ans use currentitem.value and currentitem.key

Cheers

The below is the New one that I have written.


And this is the previous one.

@Pushpendra_kowthavarapu

Please shwo the expression you have inside the assign

May be name is not recognized

Try dict(name.ToString)

Cheers

And this is the previous one.

@Pushpendra_kowthavarapu

May be when the value is changed the for loop auto casted name to object instead of string…ao try with dict(name.ToString)

Cheers

@Pushpendra_kowthavarapu

Instead of datetime.Parse use datetime.ParseExact

DateTime.ParseExact(dict(name).ToString,"Your Format",CultureInfo.InvariantCulture)

import System.Globalization

But in runtime it was giving this error.

@Pushpendra_kowthavarapu

as per error the value in dictionary for one of the key is empty , a blank string…check that

cheers

Thanks for the suggestion. I will do it .

1 Like

Hi, I tried it but still not working .

Hi @Pushpendra_kowthavarapu

Try this way:

Assign-> DicVar = New Dictionary(of String,String)

Assign-> DicVar("Varun") = "08-11-2000"

For Each currentKeyValuePairOfTextAndText in DicVar
    Assign-> str_Date = DateTime.ParseExact(currentKeyValuePairOfTextAndText.Value, "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM-dd-yyyy")
End For Each

DicVar is of DataType System.Collections.Generic.Dictionary(System.String,System.String). str_Date is of DataType System.String.


If you have more queries, I’m happy to help.

Regards