0
我使用下面的擴展從數據表中的列解壓縮到一個列表對象:數據表列出通用
public static List<string> ColumnToList(this DataTable dt, string ColumnName)
{
return dt.AsEnumerable().Select(x => x[ColumnName].ToString()).ToList();
}
北京時間它可以使用genereic datata型 - 不只是字符串 - ?在我的情況下返回值可以像List<string>, List<datetime>, List<int>, List<bool>
什麼,...
這是我的第一次嘗試 - 但它會拋出一個錯誤 – fubo 2014-12-03 14:09:53
@fubo和它引發的錯誤是? – 2014-12-03 14:10:43
方法ColumnToList的類型參數不能從用法中推斷出來。嘗試明確指定類型參數。 – fubo 2014-12-03 14:13:00