首页 新闻 会员 周边

Linq 对子符串的累加怎么写?

0
悬赏园豆:10 [已解决问题] 解决于 2012-04-24 15:24

对于int 有个SUM,如果是个字符串,如何让查询出来的结果直接累加呢(中间加个<br/>),谢谢指导!~

问题补充:

好像没有用...

Datatable Ptime  //

query = from s in ptime.AsEnumerable()
                        where s.Field<int>("phase")==1
                        select s;

如何返回 s.Field<int>("startime")列所有值累加"<br/>",成为一个string

happydaily的主页 happydaily | 菜鸟二级 | 园豆:301
提问于:2012-04-24 11:34
< >
分享
最佳答案
1
string[] words ={"one","two","three"};
var res = words.Aggregate((current,next)=> current +", "+next);
Console.WriteLine(res);
改一下,就可以了。
收获园豆:8
悟行 | 专家六级 |园豆:12559 | 2012-04-24 12:43
其他回答(1)
0

string[] sum = { "1", "2", "3" };
var res = sum.Aggregate((value, text) => value + "<br/> "+text);

收获园豆:2
┢┦偉 | 园豆:1240 (小虾三级) | 2012-04-24 13:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册