现在的位置: 首页 > 综合 > 正文

Aggregate 为字符串数组元素添加单引号 可用于SQL数据查询 in

2012年03月21日 ⁄ 综合 ⁄ 共 196字 ⁄ 字号 评论关闭
string condition = string.Empty;
int[] a = { 12131415 };
condition 
= a.Aggregate(condition, (current, i) => current + ("'" + i+"',")).Trim(',');
this.Text = condition;
 
输出结果为:'12','13','14','15'

抱歉!评论已关闭.