How to resolve the ambiguously named extension method?

I have a DataTable that I am trying to list using the AsEnumerable extension method in System.Linq.Enumerable. The problem is that System.Data.DataTableExtensions has a method with the same extension name. I need to use both namespaces in my class, so deleting one of the operators used is not an option.

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

+5
source share
2 answers

These are just static methods, so you can do this:

DataTable dt;
System.Linq.Enumerable.AsEnumerable(dt);
+3
source

DataTable IEnumerable <T> , IEnumerable, Enumerable.AsEnumerable(). DataTableExtensions.AsEnumerable().

+4

All Articles