vs2015发现一个字符串拼接 bug

VS2015支持 字符串拼接

如下:

string user="test";

int password=123;

string sql=$" user={user};password={password.ToString()} ;"

使用字符串拼接只需要在原字符串前加$即可,是不是很简单  

另外字符串拼接也可以和@并且,@是可以让字符串换行

string sql=@" user={user};
password={password.ToString()} ;"

还有,在字符串拼接中使用三元运算符 ?:

单独使用没有问题

string sql=$"user={password==0?"123":"456"}"

 但如果和@一起使用,编译器就提示错误了,郁闷

 

 

string sql=$@"user={password.ToString()};
12313123";
//没有问题

string sql=$@"user={password==0?"123":"456"}";
//提示应输入:  BUG

 大家试试看有没有出现这种问题? 

原文地址:https://www.cnblogs.com/fxyc87/p/4860180.html