C#串模板

c# 6.0 的语言特性,功能类似string.formate,更方便的地方在于不要像format一样使用索引,可以直接使用变量。

使用方法如下:

string name = "zhangsan";

console.write($"my name is {name}"); 输出  my name is zhangsan;

{} 中间可以是变量,也可以是一个方法。

 Console.WriteLine($"My name is {GetString()}"); 效果和上面一样
————————————————
版权声明:本文为CSDN博主「yr1202」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yr1202/article/details/86482937

原文地址:https://www.cnblogs.com/gloryhope/p/11661963.html