C# fianally 测试
2021-01-08 15:48 qgbo 阅读(92) 评论(0) 编辑 收藏 举报string m(int i) { try { if(i==1) throw new Exception("sss"); return "OK"; } catch { Console.WriteLine("catch Exception"); return "Exception"; } finally { Console.WriteLine("finally"); //return "finally"; 这里不能写return , 其实相当于 先的到返回值之后,执行这段代码,再返回。 } return "over"; } Console.WriteLine("resuit= "+m(1)); Console.WriteLine("-----------"); Console.WriteLine("resuit= "+m(2));
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/hello-world?tutorial-step=1 可以在这里直接运行
if (st?.Age > 13)
等价为如下
if (st != null && st.Age > 13)
气功波(18037675651)