【问题标题】:Datatable implements IEnumerable?数据表实现IEnumerable?
【发布时间】:2012-01-09 11:39:39
【问题描述】:

图片中:

AsEnumerable 方法如何知道类型应该是DataRow

我在 Reflector 中搜索过,Datatable 确实实现了 IEnumerable..

AsEnumerable 代码是:

public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source)
{
    return source;
}

我错过了什么?

【问题讨论】:

    标签: c# datatable ienumerable


    【解决方案1】:

    您正在查看错误的 AsEnumerable 方法 - 您正在调用 DataTableExtensions.AsEnumerable。而不是Enumerable.AsEnumerable

    【讨论】:

    • Reflector 没有给我看。我必须导入这个奇怪的 dll 才能看到它:( 谢谢。
    【解决方案2】:

    对于任何使用 dotnet core 并遇到相同问题的人,您需要在 Nuget 中添加“System.Data.DataTableExtensions”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多