Operator ">" is not defined for type Dictionary (of String,Int32)

Hey Everyone,
I am facing the following issue.


I am not getting how can i resolve this operator issue.

Your suggestions are appreciable.
Thank you

@nashrahkhan

Have you installed Microsoft.Activities.Extension package in your process?

Regards
Anand

@anandji05 I have checked. It has no impact on this.

you are using object dictionary and not that way how to use it.

this is way how to use it
as example:
winner(keyname)

and then you want to compare the value by using “>”

first thing u need to convert the string to be integer
as example
int32.parse(winner(keyname).value) > 1

hope it can help you.

Dictionary.xaml (6.7 KB)
may this help you.

Main.xaml (9.2 KB)
Kindly look in to it.
I am not getting any solution of it. I have tried all the told methods.

Hi @nashrahkhan,

Check this below link:

Thanks,
Neelima.

now I am getting this error.

@nashrahkhan

Hello Nashrah,
you can use a tiny trick to get the information you need. Use instead of the Winner object an index.

I defined a counter variable i and in the loop the variable is increased. This variable is the index of your WinnerCounts dictionary and with WinnerCounts.Values(i) you get the value and with WinnerCounts.Keys(i) you get the key.

Here my code to set the dictionary:

Dim WinCnts As New Dictionary(Of String, Integer)
WinCnts.Add("Stefan", 1)
WinCnts.Add("Nashrah", 2)
WinnerCounts = WinCnts

And her my result:
image

Maybe not elegant, but it works.

This loop is an alternative and better to understand, without an additional Winner object.

Best regards
Stefan

1 Like

Hi,

The issue is related to how you have created the loop. In your case, you have declared the Winner item of type Dictionary<string, integer>, and the Winner.Values is a collection of items. The error say that you cannot apply operator “>” on a collection. In order for your code to work, is to change the type of TypeArgument, to be of Type KeyValuePair<string, int>, and then use Winner.Value > 1.


3 Likes

Great tip @Maria2na :+1:

@StefanSchnell @Maria2na
THANK YOU FOR YOUR TIPS :slight_smile:
IT GOT RESOLVED

1 Like

great tips… thanks a lot…

@Maria2na excelent. Thank you!

Glad to help!