Multiple key value pairs todictionary

Hello i have been trying to convert a datatable into dictionary using this code:

(From d In dt.AsEnumerable
Let kvp = New KeyValuePair(Of string, string)(d(1).toString,d(2).toString)
Select kvp).ToDictionary(of string, string)Function (x) x.Key, Function (x) x.Value)

My question is what if i need to define multiple kvps based on a specific column of the dt, example

mydt would be like this

Category:KeyColumn:ValueAColumn:ValueBColumn
Cat1:Key1:A:a
Cat2:Key2:B:b

my dictionary should look like this

{Key1,A},
{Key2,b}

Appreciate your help guys.

Thanks

@ZARA_Clark_Vincent_M

find some starter help here:
DtToDict_MultiKVP.xaml (10.1 KB)

Hello @ZARA_Clark_Vincent_M
on what condition you will be deciding the when to choose col A and when to choose col B…?

Thanks Peter it worked

in the example i provided it is based on category column. Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.