c# 7.0的语法主要是优化了之前的写法,使得更加简洁方便。try catch when  这个使用场景很少,正常的开发无业务处理的时候不建议使用 。

#region 2.字符串嵌入值
console.writeline(“____________字符串嵌入值____________”);
console.writeline(string.format(“当前时间:{0}”, datetime.now.tostring()));

console.writeline($”6当前时间:{ datetime.now.tostring()}”);
#endregion

#region 3.空值运算符
console.writeline(“____________空值运算符____________”);
string name = null;
console.writeline(string.isnullorempty(name) ? “” : name.tostring());//避免空异常

string str = string.empty;
console.writeline(name?.tostring());
#endregion

#region 4.异常过滤器
console.writeline(“____________异常过滤器____________”);
int exceptionvalue = 10;
try
{
int32.parse(“s”);
}
catch (exception e)
when (exceptionvalue > 1)//满足条件才进入catch
{
console.writeline(“catch”);
}
//quartzmanager.addjob(“datetimeupdate”, “test”, “consoleapp.demojob”, “0/20 * * * * ?”);
#endregion
console.readline();