Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a HashSet from a column of DataTable

Tags:

c#

.net

Is there a built in way (LINQ maybe?) of taking all the row values from a specific column from a DataTable and creating a HashSet from it? The column is also of type String.

I could obviously do this in a loop but I was wondering if there is another way?

I'm using .net 3.5 btw.

Thanks,

AJ

like image 991
AJ. Avatar asked Oct 15 '25 13:10

AJ.


1 Answers

Use HashSet<T> Constructor (IEnumerable<T>)

Reference: http://msdn.microsoft.com/en-us/library/bb301504.aspx

like image 156
Kirill Polishchuk Avatar answered Oct 17 '25 02:10

Kirill Polishchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!