I want to store multiple key value pair at a time in the same dictionary.
Hi @siddhi.rani ,
Could you maybe provide us with an Example data of how you would want the data mapping to be done ?
From the Topic name, it seems you need Tuple type. But from the explanation above it seems just a Dictionary Key Vaue pair is enough.
Let us know some more details of your expected data representation and we could suggest the appropriate type/approach.
Consider a sheet which contains working hours (month wise full year data ) of multiple employees , so i want the output data in the below form:
Raj , { (March-21, 100) , (April-21 ,120) , (May-21 , 100)…so on }
where 100, 120… are hours.
For that I’ve used this “Dictionary<string, Tuple<int, string>>”, but I’m getting result of only one month at a time. In next iteration new output overrides the data of previous ones.
Hi,
Perhaps you should use Dictionary<string, List<Tuple<string,Int32>>>
for your requirement.
I think it might be better to use Dictionary<string, Dictionary<String,Int32>>
, if year-month is uique for each person.
The following is a sample for the both.
dictLIstTuple = dt.AsEnumerable.GroupBy(Function(r) r("Name").ToString).ToDictionary(Function(g) g.Key,Function(g) g.Select(Function(r) Tuple.Create(r("Date").ToString,CInt(r("Value")))).ToList)
dictDict = dt.AsEnumerable.GroupBy(Function(r) r("Name").ToString).ToDictionary(Function(g) g.Key,Function(g) g.ToDictionary(Function(r) r("Date").ToString,Function(r) CInt(r("Value"))))
Sample20230419-1aL.zip (2.8 KB)
Regards,