ASP.NET创建字符串 [英] Asp.net create string

查看:68
本文介绍了ASP.NET创建字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参见以下代码:
SqlConnection con = Database.GetConnection();
字符串column_names =";
字符串值=";
foreach(user_data as key => value){
column_names = column_names +键+,";
值=值+值+;
}
//从字符串末尾删除,".
SqlCommand com =新的SqlCommand(插入成员(column_names)values(values)",con);

我想使用c#创建此文件.
请任何人帮我....在此先感谢

see the below code:
SqlConnection con = Database.GetConnection();
String column_names = "";
String values = "";
foreach(user_data as key=>value){
column_names = column_names + key+",";
values = values + values+;
}
// remove "," from end of string ..
SqlCommand com = new SqlCommand("insert into members(column_names) values(values)", con);

I want to create this using c#.
Please any one help me....Thanks in advance

推荐答案

要删除字符串中的最后一个逗号,您可以执行以下操作:

string foo = "a,b,c,d,e,f,".TrimEnd('','');
To remove the final comma in a string you can do something like:

string foo = "a,b,c,d,e,f,".TrimEnd('','');


这篇关于ASP.NET创建字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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