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,303
  • 3
  • 41
  • 54
uzay95
  • 16,052
  • 31
  • 116
  • 182
  • 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
  • 10,106
  • 3
  • 45
  • 71
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
  • 30,108
  • 19
  • 83
  • 131