只是好奇:为什么C#中的try catch语法(Java也?)为多个语句硬编码?为什么语言不允许:
int i; string s = DateTime.Now.Seconds % 2 == 1 ? "1" : "not 1"; try i = int.Parse(s); catch i = 0;
这个例子只是为了琐碎的目的.我知道有int.TryParse.
int.TryParse
c# try-catch
c# ×1
try-catch ×1