首页 > 其他 > 详细

Interpolated Strings

时间:2015-11-17 12:26:14      阅读:189      评论:0      收藏:0      [点我收藏+]

https://msdn.microsoft.com/en-us/library/dn961160.aspx

int apples = 4;
// Before C# 6.0
System.Console.WriteLine(String.Format("I have {0} apples", apples));
// C# 6.0
System.Console.WriteLine($"I have {apples} apples");

 

var result = string.Format("{0}{1}{2}{3}", tempChannelId, tempIndex, tempType, tempDeviceId);

升级为

var result = $"{tempChannelId}{tempIndex}{tempType}{tempDeviceId}";

优越性在于,不需要考虑{0}{1}{2}{3}和后面的变量的顺序对应

 

Interpolated Strings

原文:http://www.cnblogs.com/chucklu/p/4970992.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!