Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve ambigiously named extension method?

I have a DataTable that I'm trying to enumerate over with the AsEnumerable extension method on System.Linq.Enumerable. The problem is that there is an identically named extension method on System.Data.DataTableExtensions. I need to use both namespaces in my class so removing one of the using statements is not an option.

How do I declare that I want the AsEnumerable method from System.Linq.Enumerable and not the System.Data.DataTableExtensions?

like image 231
Jace Rhea Avatar asked Jun 04 '10 19:06

Jace Rhea


1 Answers

DataTable does not implement IEnumerable<T>, or even IEnumerable, so you cannot call Enumerable.AsEnumerable() on it directly. That is what DataTableExtensions.AsEnumerable() is for in the first place.

like image 176
BlueRaja - Danny Pflughoeft Avatar answered Oct 03 '22 03:10

BlueRaja - Danny Pflughoeft