I’m new to C-sharp. Trying to approach the following issue while avoiding unsafe code.
Sorry if my description seems excessive; just trying to be as clear as possible.
I’m reading a file that has the following format:
Column1 Column2 Column3
1 a q
1 a w
2 a b
1 e v
3 w q
3 q x
... ... ...
I’m trying to create a data structure such that every unique item in “column1” is linked to a{ column2 , column3} pair. Something like this:
{1} => {a, q}, {a,w} , {e,v}
{2} => {a,b}
{3} => {w,q} , {q,x}
The issue here is that you don’t know in advance how many different unique items “column1” will have. So far, I have dealt by creating listdictionary variables in advance so that I can just “.add()” the pairs.
If I were doing this in C++, I would have some kind of array holding pointers to a structure holding {column2, column 3} pairs.I admit this might not be the best solutions, but it is the line of thought I was following in C#.
In short, I’m asking for suggestions on how to dynamically create a listdictionary , or if there is a better way to approach the problem.
Assuming that you have the line content on a array, you can work with something like this:
Regards