Note that there are some explanatory texts on larger screens.

plurals
  1. POList containing Dictionary Containing List
    primarykey
    data
    text
    <p><strong>Question</strong></p> <p>I need a data structure like the above in C# but I am having problems accessing the contents, I have seen that I can do this in C++ how is the same done in c#?</p> <pre><code>List&lt;Dictionary&lt;string, List&lt;int&gt;&gt;&gt; data = new List&lt;Dictionary&lt;string, List&lt;int&gt;&gt;&gt;(5); </code></pre> <p>when i do Data[0] i get an error stating index out of bounds..</p> <p>Can anyone point me as to how I can do this. or what I am doing wrong ? </p> <p><strong>Addendum:</strong></p> <p>-><em>What im trying to do</em> </p> <p>I am basically creating a data structure which keeps a plan of the month. So a List of the 5 weeks each containing-> a Dictionary of activities, where the value for each activity is a -> list of 7 integers representing the hours spent each day of the week on that activity.</p> <p>I have got that I need to add blank entries. Additional Question is like this.</p> <p>-><em>Query</em></p> <p>Right now I will have to Add 5 blank dictionaries to the list. and a list of 7 integers(initialized to zero) in each Key of the dictionary representing each days time consumed.</p> <p>Is there a way to initialize 5 blank dictionaries in the list and same inside, without manually creating new dictionaries and adding them. With c++ i believe that you can do this and even enter the value to which you want to initialize each entry to be, so..</p> <p>A statement like </p> <pre><code>Vector&lt;int&gt; *vec = new Vector&lt;int&gt;(5,0); </code></pre> <p>Initialized the vec with 5 entries each being 0. Can I do the same in c# ? </p> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload