How do I exit from a function?

前端 未结 7 1295
野的像风
野的像风 2021-02-18 20:18

i know that in vb.net you can just do Exit Sub

but i would like to know how do i exit a click event in a button?

here\'s my code:

pr         


        
7条回答
  •  感情败类
    2021-02-18 20:53

    There are two ways to exit a method early (without quitting the program):

    i) Use the return keyword.
    ii) Throw an exception.

    Exceptions should only be used for exceptional circumstances - when the method cannot continue and it cannot return a reasonable value that would make sense to the caller. Usually though you should just return when you are done.

    If your method returns void then you can write return without a value:

    return;
    

提交回复
热议问题