Interpolated Strings
2015-11-17 10:49
169 查看
https://msdn.microsoft.com/en-us/library/dn961160.aspx
var result = string.Format("{0}{1}{2}{3}", tempChannelId, tempIndex, tempType, tempDeviceId);
升级为
var result = $"{tempChannelId}{tempIndex}{tempType}{tempDeviceId}";
优越性在于,不需要考虑{0}{1}{2}{3}和后面的变量的顺序对应
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}和后面的变量的顺序对应
相关文章推荐
- UGUI制作动态ScrollView注意点
- 谈谈个人对Spring的理解
- linux下tar.gz、tar、bz2、zip等解压缩、压缩命令小结
- perl获取时间
- WebView的加载网页
- 行人检索 Partial Person Re-identification ICCV2015
- Java之控制反转和依赖注入
- finished with non-zero exit value 1 解决办法
- 利用html标签限制搜索引擎对网站的抓取收录
- webservice快速入门
- yii2 log的使用
- linux配置防火墙iptables实例分享
- LeetCode:Implement Stack using Queues
- extern "C"的用法解析
- 原子操作
- LightOJ 1011 Marriage Ceremonies
- xcode插件管理器
- MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法
- C# \\u8888类型的unicode转换为字符串方法
- 利用FlexPaper实现Word、PPT、PDF在线浏览