1

How can I create a dictionary containing ints as keys and arrays as Values. Here is what I have tried on dotnetfiddle.net with no luck:

Dictionary<int, double[]> dict;
double[] prices = new double[20];
dict = new Dictionary<int, prices>();

Dictionary<int, double[]> dict;
dict = new Dictionary<int, new double[20]>();

Dictionary<int, double[]> dict;
dict = new Dictionary<int, double[20]>();
1
  • 2
    Dictionary<int, double[]> dict = new Dictionary<int, double[]>(); ? Commented Mar 12, 2019 at 16:16

1 Answer 1

6

You can try this.

Dictionary<TKey,TValue> is a generic type you can only set contracts type on it.

I think you are looking for Add method to add double array.

Dictionary<int, double[]>  dict = new Dictionary<int, double[]>();
dict.Add(1,new double[20]);
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.