static int F(int a, int b) {
throw声明 and try声明 if (b == 0)
throw new Exception("Divide by zero");
return a / b;
}
static void Main() {
try {
Console.WriteLine(F(5, 0));
}
catch(Exception e) {
Console.WriteLine("Error");
}
}
static void Main() {
checked和unchecked声明 int x = 100000, y = 100000;
Console.WriteLine(unchecked(x * y));
Console.WriteLine(checked(x * y)); // Error
Console.WriteLine(x * y); // Error
}
static void Main() {
lock声明 A a = ...
lock(a) {
a.P = a.P + 1;
}
}