美文网首页
.net core 中 String常量前 @和$符号的用法

.net core 中 String常量前 @和$符号的用法

作者: 小孙2018 | 来源:发表于2018-08-11 23:29 被阅读0次

String 用法。

@表示不进行转义。

比如

String testStr= @" line1 \' 

this is line2 \j

this is line3 

"

除了双引号,所有字符都不会被转义

var name = "Chilly";

Console.WriteLine($"Hello,{name}. It's a pleasure to meet you!");

$表示启用占位符{},这里 {name} 会被替换成Chilly.(和StringFormat() 用法相似)

相关文章

网友评论

      本文标题:.net core 中 String常量前 @和$符号的用法

      本文链接:https://www.haomeiwen.com/subject/wpyjbftx.html