Hello, not sure if this was discussed already, im looking for a code to convert datatable to dictionary without using for each loop.
In general it is about:
left side your dict
YourDataTableVar.AsEnumerable.ToDictionary(Of String, String)(Function (r) r(YourKeyCol).toString, Function (r) r(YourValueCol).toString)
thank you so much, it works. just a follow up question, if the value is a tuple, more than 1 string value, how should i edit the formula?
are you talking about a tuple (the
tuple<T> Class) or a string Array / List
however it will change the dictionary definition
ToDictionary(Of String, OtherDataType)
and the value retrieval function
Function (r) r(YourValueCol)
find starter help here:
DtToDict_1Key2Val_StringTuple.xaml (6.9 KB)
Hello, yes tuple…to be more specific, tuple<t1,t2>…how to change the value retrieval function…should it be Function ® r(YourValueCol1,YourValueCol2)?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.