Vs 2015 中一些新的语法支持
2015-07-21 17:22
381 查看
又是语法糖。
1,
if (tdata != null && tdata.Data != null)
等价于
if (tdata?.Data != null)
2,
int a = 1 ;
var y = string.Format(“xyz{0}”,a);
相当于
var y = $"xyz{a}";
3,
private _cacheToUser = null;
public string CacheToUse
{
get { return _cacheToUse; }
set { _cacheToUse = value; }
}
相当于
public string CacheToUse { get; set; } = null;
4,
private string _s;
public string S
{
get { return _s; }
}
相当于
private string _s;
public string S => _s;
1,
if (tdata != null && tdata.Data != null)
等价于
if (tdata?.Data != null)
2,
int a = 1 ;
var y = string.Format(“xyz{0}”,a);
相当于
var y = $"xyz{a}";
3,
private _cacheToUser = null;
public string CacheToUse
{
get { return _cacheToUse; }
set { _cacheToUse = value; }
}
相当于
public string CacheToUse { get; set; } = null;
4,
private string _s;
public string S
{
get { return _s; }
}
相当于
private string _s;
public string S => _s;
相关文章推荐
- roject ..\appcompat_v7 is missing. Needed by eclipse 转AS项目时遇到的问题
- Android-各个屏幕的logo尺寸要求
- 男子误进女厕打死服务员 网友:在牢里绝进不错厕所
- 隧道和网络虚拟化:NVGRE vs VXLAN
- HDU 2473Junk-Mail Filter 【并查集,删点】
- Undefined symbols for architecture i386:和"_OBJC_CLASS_$_xx", referenced from:问题解决方法
- 设计模式-原型模式(Prototype)
- php后台管理员权限相关表结构
- Maven学习----------基础
- 15-07-17 数据库练习题
- DTCMS插件的制作实例电子资源管理(二)Admin后台页面编写
- Nodejs 安装 grunt ,Webstorm grunt 配置
- 【C语言】再次找的一些C语言题目,关于折半查找和某些种种
- How HashMap works in Java
- 文件 操作
- git的实际操作用法
- logback使用
- ffmpeg + m3u8-segmenter 配置
- hibernate连接mysql所需的jar包
- 1154 能量项链