繁体   English   中英

在公共 static void mvc 属性中尝试捕获异常处理后,我如何拒绝继续子代码行

[英]How can i deny continue the sub code lines after the try catch exception handling in public static void mvc property

我有一个 static class 和一些 static 空属性。

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
        }
} 

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

您可以像这样使用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
        }
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM