How to add row values into list/Dictionary/Array

PFA,

I have an Excel sheet it contains two columns part number, qty
I am trying to store all the part number values into one array/list/dictionary & all Qty values array/list/dictionary

Can anyone guide me on how to do that

Thanks in advance

Hi @rsr.chandu ,

You can use the below expression to convert it to dictionary:

DT.AsEnumerable.ToDictionary(Function(x)x("partnumber").ToString,Function(y)y("quantity").ToString)

Regards,

2 Likes

Hi,

If partnumber is unique in the table, I recommned to use Dictionary as the following.

image

dict = dt.AsEnumerable.ToDictionary(Function(r) r("partnumber").ToString,Function(r) r("quantity").ToString)

note : dict is Dictionary<string,string> type

Regards,

1 Like

How to loop through the created dictionary?
How to check whether it is empty or having some values

@rsr.chandu ,

You can use the for each item and an if condition inside to check whether the key or value is null/empty
image

Regards,

1 Like

Hi,

We can check it using Count property as the following.

image

Regards,

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