日期:2014-05-17  浏览次数:20838 次

一个简单得吓死你的问题。
在.net 环境下(我用的是vb,估计c#也差不多。)
怎样用多行来描述一个字符段。

比如
dim a as string
  a="select * 
     from xxxx as a
     where xxxxx
    "

原因就是我要写sql语句,如果不用多行来写,可读性太差。



------解决方案--------------------

//是这样么
string a="";
a+="select *  from xxxx as a ";
a+="where xxxxx ";

------解决方案--------------------
using System.Text;

StringBuilder str = new StringBuilder();
str.Append("1");
str.Append("2");

str.ToString()
------解决方案--------------------
引用:
Quote: 引用:


//是这样么
string a="";
a+="select *  from xxxx as a ";
a+="where xxxxx ";




我的意思是,一个字符串的赋值命令能分成几行来写吗,只要在他每行的后面加上一个什么继续的符号,
让他知道下一行仍然是这个字符串的一部分。
主要是想让我的sql语句可读性高一点,不是字符串的合并。




            string s = @"select * 
              from xxxx as a
               where xxxxx";

            string s = "select * " +
                "from xxxx as a"
                + "where xxxxx";


------解决方案--------------------

"aaaa" _
& "bbbb" _
& "cccc"

------解决方案--------------------