How to fetch first value in specific column

Hi Team,
I need to fetch first value from column using LINQ.
ie"Year" is equal to 2021

I have tried like this
dt1.AsEnumerable.Take(1).Select(Function® r(“Year”).ToString.Trim )

image

@Sharanabasava

To fetch the first value of a particular column then check as below
dt.Rows(0).Item(“Year”).ToString

Hope this may helps you

Thanks

I don’t want to use loop

@Sharanabasava The option that has given @ksrinu070184 does not need a loop, you just have to assign it to a string

@Sharanabasava

I didn’t use any loop you will get direct value from the DT as @Hiba_B said

Thanks

If you want linq then you can make below changes in your code

varDT.AsEnumerable.Take(1).Select(function® r(“Year”))(0)

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