在C#.net中使用linq将数据表转换为字符串数组时出错 [英] Error while converting datatable to string array using linq in c#.net

查看:112
本文介绍了在C#.net中使用linq将数据表转换为字符串数组时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含两列Id和Total的数据表.

我想将此数据表转换为字符串数组.
我正在尝试以下代码:

I have data table with two columns Id and Total.

I want to convert this data table to string array.
I am trying following code:

//use LINQ method syntax to pull the Title field from a data table into a string array...
string[] postSource = dtPosts
                    .AsEnumerable()
                    .Select<System.Data.DataRow, String>(x => x.Field<String>("Title"))
                    .ToArray();
var source = new AutoCompleteStringCollection();
source.AddRange(postSource);




但它不起作用
请帮助




But its not working
pls help

推荐答案

看看
Hi Have a look HERE[^]. May be helpful.


这篇关于在C#.net中使用linq将数据表转换为字符串数组时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆