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

 大家試試看有沒有出現這種問題? 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM