0

AsEnumerable is converting something into something(generic or not). There is picture below:

enter image description here

I wonder that how AsEnumerable converting string array to string[] but DataTable to EnumerableRowCollection<DataRow> ?

Pilgerstorfer Franz
  • 8,253
  • 3
  • 41
  • 53
uzay95
  • 15,294
  • 28
  • 111
  • 175
  • 1
    Are you sure that `ver` is not produced by calling [this method](http://msdn.microsoft.com/en-us/library/system.data.datatableextensions.asenumerable%28v=vs.100%29.aspx)? Because `ear` is produced by calling [this *other* method](http://msdn.microsoft.com/en-us/library/bb335435.aspx). – Jon Aug 24 '12 at 08:21
  • 3
    It is because they are different extension methods - one for datatable and other for enumerable – JleruOHeP Aug 24 '12 at 08:21
  • have you seen this: http://stackoverflow.com/questions/2013846/why-use-asenumerable-rather-than-casting-to-ienumerablet – BizApps Aug 24 '12 at 08:24

2 Answers2

3

They are different Extension methods. One is DataTableExtensions.AsEnumerable and other is Enumerable.AsEnumerable

JleruOHeP
  • 9,476
  • 3
  • 38
  • 68
1

Because both AsEnumerable are different

With String array, AsEnumerable returns IEnumerable<T>.

Refer to Enumerable.AsEnumerable

DataTable.AsEnumerable is defined in DataTableExtensions. It returns EnumerableRowCollection < DataRow >

Tilak
  • 28,854
  • 17
  • 79
  • 129