LINQ Query to Convert Data Column Values to List

I need a linq query to convert particular excel column data to List

Input:

Name Marks
John 123
Bob 435
Rony 34
Jimmy 54

Expecte output: {“John”,“Bob”,“Rony”,“Jimmy”}

Hi @Random_Bot ,

You can do this as below

Assign ----> Name as List [System.Collections.Generic.List] :

(From row In dt_input.AsEnumerable() Select Convert.Tostring(row("Name")) ).ToList()

Regards,
Vinit Mhatre

1 Like

Hi @Random_Bot

Try this linq:

namesList = (From row In dt.AsEnumerable() Select row.Field(Of String)("Name")).ToList()

namesList is of DataType System.Collections.Generic.List(Of String)

Regards

1 Like

Thanks @Vinit_Mhatre and @Parvathy

1 Like

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