我想在中国做类似的事情.净3.5.最快的方法是什么?

IEnumerable<DataRow> collection = 
    TypedDataSet.TypedTableBase<DataRow>.Rows as IEnumerable<DataRow>;

推荐答案

假设你正在使用.NET 4.0,它引入了协方差:

// Presumably your table is of some type deriving from TypedTableBase<T>,
// where T is an auto-generated type deriving from DataRow.
IEnumerable<DataRow> collection = myTypedTable;

table type itself实现了IEnumerable<T> where T : DataRow.

否则:

IEnumerable<DataRow> collection = myTypedTable.Cast<DataRow>();

.net相关问答推荐

.NET restore/build在使用组织包的Github Action工作流中调用时获得401

";Make Async ValueTask/ValueTask方法分期分配发生了什么?

如何将多个安装程序Bundle 到一个安装程序中?

如何将 Assembly.CodeBase 转换为 C# 中的文件系统路径?

单线程单元 - 无法实例化 ActiveX 控件

为什么 SortedSet.GetViewBetween 不是 O(log N)?

如何摆脱 VS2008 中的目标程序集不包含服务类型错误消息?

IIS Express - 500.19 无法读取配置文件 - 因为它正在查看错误的路径

使用 C# 清除文本文件的内容

为什么 WCF 中不允许方法重载?

如何判断对象是否是某种类型的数组?

在 .NET 中查找下一个 TCP 端口

在 .NET 中填充整数列表

在同一解决方案中引用 2 个不同版本的 log4net

在 .NET 中获取默认打印机的最佳方法是什么

将 Dictionary 转换为匿名对象?

C# List<> 按 x 然后 y 排序

如何使用通用扩展方法中的字符串列名在 IQueryable 上应用 OrderBy?

WinForms 中的模型视图演示者

如何在 ASP.NET MVC 中重定向到动态登录 URL