1

我有一个带有一些静态 void 属性的静态类。

public static class Payment
{
   public static void ChargeTask(int paymentId)
        {
          //some code
           try
            {
               //some code
            }
           catch
            {
              //handle the exceptions. 
             how can i exit in this property
            }
          //deny continue this codes
        }
} 

在尝试捕获异常处理后,我如何拒绝继续子代码行?

4

1 回答 1

1

你使用return这样的关键字:

public static class Payment
{
   public static void ChargeTask(int paymentId)
        {
          //some code
           try
            {
               //some code
            }
           catch
            {
              //handle the exceptions. 
              return;
            }
          //deny continue this codes
        }
} 
于 2020-08-01T20:01:05.077 回答