Matthew Matthew - 8 months ago 38
C# Question

How to get from Dictionary<char, Tuple <int, char>> int value for specific key?

I have 2 dictionaries in first case I used Tuple for key values and it works fine like this

Dictionary<Tuple<char, char>, int> pairPoints = new Dictionary<Tuple<char, char>, int>();
foreach (var items in this.pairPoints)

but in second case I want to get value which is also in Tuple {int,char} however I cant find something like result.Values.Item1

Dictionary<char, Tuple <int, char>> result = new Dictionary<char, Tuple<int, char>>();
if(distance < result.Values.Item1) {//do my things}

Is it possible to write it something like this or do I have to use different array method?


result.Values is a collection of Tuple<int, char> You can access a single item in the collection by the dictionary key:


Or you can loop though all the values as follows:

foreach(var tuple in result.Values)