String NoteId = //....;
String userName = //....;写法一:
strSql = "delete from admin";
strSql = String.Concat(strSql, " where id = ", NoteId);
strSql = String.Concat(strSql, " and UserName = '", userName, "'");写法二:
strSql = "delete from admin where id = {$id} and UserName = '{$UserName}'";
this.SqlStr = this.SqlStr.Replace("{$id}", NoteId);
this.SqlStr = this.SqlStr.Replace("{$UserName}", userName);为了公平,所以写法一二都是用了三个句子写成,请问写法一和写法二,哪个效率高点?
String userName = //....;写法一:
strSql = "delete from admin";
strSql = String.Concat(strSql, " where id = ", NoteId);
strSql = String.Concat(strSql, " and UserName = '", userName, "'");写法二:
strSql = "delete from admin where id = {$id} and UserName = '{$UserName}'";
this.SqlStr = this.SqlStr.Replace("{$id}", NoteId);
this.SqlStr = this.SqlStr.Replace("{$UserName}", userName);为了公平,所以写法一二都是用了三个句子写成,请问写法一和写法二,哪个效率高点?
解决方案 »
- 初学数据结构链表中有点不明白的,高手过来指导下。
- 用dataset填充datagridview,清空datagridview问题
- asp.net(c#)发布后无法插入更新数据
- 如何读取图片某一区域?
- 如何从一个html原代码中分析出所有的连接?
- 钩子问题
- 怎么样实现"颜色下拉comboBox"?
- [急!100分]如何用C#写绘图代码,请高手帮帮忙啊
- 文件下载保存问题
- 在数据库的temp字段中中放入:Response.Write("您好!");现在C#中读出,如何显示并运行这一行程序?
- 关于“ System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。”的错误,请教
- Response.write的问题:如何使得请求端只获得Response.write的值,而忽略html代码
strSql = "delete from admin where id = {0} and UserName = '{1}'";
strSql = string.Format(strSql, NoteId,userName);
string.Format 也应该不会快于第一个,内存分配次数也>=2
平民大哥 string.Format 的原理是什么?能给说说吗?(很感兴趣)
string userName = "ddddd"; strSql = "delete from admin";
strSql = String.Concat(strSql, " where id = ", NoteId);
strSql = String.Concat(strSql, " and UserName = '", userName, "'"); string SqlStr = string.Empty; SqlStr = "delete from admin where id = {$id} and UserName = '{$UserName}'"; SqlStr = SqlStr.Replace("{$id}", NoteId); SqlStr = SqlStr.Replace("{$UserName}", userName); string strSql1 =string.Empty;
strSql1 = "delete from admin where id = {0} and UserName = '{1}'";
strSql1 = string.Format(strSql, NoteId,userName);