2

I have a dictonaty containing an int and a tuple.

I want to insert some values when instantiating, but I'm getting an error:

Cannot convert from 'System.Tuple' to 'System.Collections.Generic.IEqualtyComparer

This is what I'm trying to do:

public static readonly Dictionary<int, Tuple<int, double>> DIAMETER_METRIC_CHAMFER 
        = new Dictionary<int, Tuple<int, double>>({80, new Tuple<int, double>(16, 37.0)}
);

1 Answer 1

7

You have passed element {80, new Tuple<int, double>(16, 37.0)} into dictionary's constructor, you should use initializer instead:

public static readonly Dictionary<int, Tuple<int, double>> DIAMETER_METRIC_CHAMFER
        = new Dictionary<int, Tuple<int, double>>() 
            { 
                { 80, new Tuple<int, double>(16, 37.0) } 
            };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.