开发者

How to kick out of a subrutine and start at the next line on the existing subrutine 3 or 4 subrutines up?

开发者 https://www.devze.com 2023-01-09 17:13 出处:网络
Basically I have something like this: public void Form1_btnStart_click() { 开发者_StackOverflow中文版Void1()

Basically I have something like this:

public void Form1_btnStart_click()

{

开发者_StackOverflow中文版Void1()

NextLine

}

Public void Void1()

{

Void2()

}

I need to get out of Void2 or beyond and go to the "NextLine" spot. Other than putting an if statement after each subroutine to see if a certain value is met and then using "return;", which would cause some problems since this is a large program which means that this change wouldn't necessarily be corrected for every possible button that eventually uses this Void2() subroutine and could even break it under many circumstances. Any ideas?


Throw a custom exception, and wrap your call to Void1() in a try...catch block to catch it.

0

精彩评论

暂无评论...
验证码 换一张
取 消