Hello, Can anyone let me know how to check that all the values in the dictionary are same? Eg. I have a dictionary with three key and value pairs, so in my case it should return true
Regards,
Manoj Kumar V
Hello, Can anyone let me know how to check that all the values in the dictionary are same? Eg. I have a dictionary with three key and value pairs, so in my case it should return true
Regards,
Manoj Kumar V
it is depending to the datatype of the dictionary values.
Give a try at
Assign Activity
myCheckBoolean | Boolean =
myDictVar.Values.Distinct().Count = 1
and if the values are different I need the respective key for that key value pair.
give us some sample data for both cases
in general we can flip it by
myReverseDict =
(From kvp in myOrigDict
Group kvp by k=kvp.Value into grp=Group
Let kl = grp.Select(Function (x) x.Key).toArray
Select t = Tuple.Create(k, kl)).ToDictionary(Function (t) t.Item1, Function (t) t.Item2)
Eg:
New Dictionary(of String, Boolean) from {{“Escalation Time”,EscalationTime},{" Resolution Time",ResolutionTime},{“Response Time”,ResponseTime},{“Resolution Elapsed Time”,ResolutionElapsedTime}
Case 1: If all the values are same i.e true since it is a type boolean then I should get passed a output message.
Case 2; If the value of any key is not similar to rest of the values and it should return failed as output message with the respective key of mismatched value.
Thanks in advance!
Manoj Kumar V
It looks like that the initial description and the description along with the sample values is divergent. We hope that in the explanation the KeyValuePair Key and the KeyValuePair Value is not mixed up and are used strict.
{
{“Escalation Time”,EscalationTime},
{" Resolution Time",ResolutionTime},
{“Response Time”,ResponseTime},
{“Resolution Elapsed Time”,ResolutionElapsedTime}
}
what is meant: key=value from an entry? or all keyvaluepairs do have the same value, so above sample data would be FALSE
Dict type : Key = String and Value = Boolean
Case1: Dict = {“Resolution Time”,True},{“Response Time”,True},{“Resolution Elapsed Time”,True}
Output : Passed
case2 : Dict = {" Resolution Time",True},{“Response Time”,True},{“Resolution Elapsed Time", False}
Output : Failed
Missing Item : Resolution Elapsed Time (Key of respective value)
Can someone help me out on this?