gpt4 book ai didi

c# - 我应该使用 goto 语句吗?

转载 作者:太空狗 更新时间:2023-10-29 23:55:16 25 4
gpt4 key购买 nike

<分区>

我有一段代码如下:

try
{
Work:

while(true)
{
// Do some work repeatedly...
}
}
catch(Exception)
{
// Exception caught and now I can not continue
// to do my work properly

// I have to reset the status before to continue to do my work
ResetStatus();

// Now I can return to do my work
goto Work;
}

与使用 goto 相比,是否有更好的选择?或者这是一个好的解决方案?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com