灵感来自问题
在我问这个问题之前,我读过:
问题的挑战是
编写一个程序,该程序具有可访问的 goto 语句,但相应的标记语句不可访问 - Eric Lippert
一个可行的答案是
// the 3 lines are not important but declare variable for afterwards use
var whateverException=new Exception("whatever exception");
var whateverAction=default(Action);
whateverAction=() => whateverAction();
try {
goto whateverLabel; // (1) the goto is reachable
}
finally {
throw whateverException; // (3) because finally hijacks
}
whateverLabel: // (2) but the label is not really reached
whateverAction();
我想知道在单线程程序中,是否只有一个可访问的 goto 指向不可访问的标签?下面的代码是否也被认为是一个可行的答案?
here:
int d=0, n=1/d;
goto here;