AssertinC#&Java-创新互联

Assert是什么?

断言(Assertion)是一种调试程序的方式。AssertinC#&J
ava

C#中的Assert

In a debug compilation, Assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
If you compile in Release, all Debug.Assert's are automatically left out.

创新互联服务紧随时代发展步伐,进行技术革新和技术进步,经过十多年的发展和积累,已经汇集了一批资深网站策划师、设计师、专业的网站实施团队以及高素质售后服务人员,并且完全形成了一套成熟的业务流程,能够完全依照客户要求对网站进行做网站、成都做网站、建设、维护、更新和改版,实现客户网站对外宣传展示的首要目的,并为客户企业品牌互联网化提供全面的解决方案。

ref: https://stackoverflow.com/questions/163538/c-sharp-what-does-the-assert-method-do-is-it-still-useful

Java中的Assert

Assertions (by way of the assert keyword) were added in Java 1.4. They are used to verify the correctness of an invariant in the code.

code

 public static void main(String[] args) {
      String name = null;
      assert (name != null) : "name is null, maybe a bug";
      System.out.println(name);
   }

JVM start args

"vmArgs":"-ea" //enable assertions

result

Exception in thread "main" java.lang.AssertionError: name is null, maybe a bug
        at App.main(App.java:7)

ref:https://stackoverflow.com/questions/2758224/what-does-the-java-assert-keyword-do-and-when-should-it-be-used


标题名称:AssertinC#&Java-创新互联
文章转载:http://bzwzjz.com/article/iphis.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站建设 成都网站制作 移动手机网站制作 网站建设方案 成都网站设计 成都网站设计 成都网站制作 手机网站建设 成都网站设计 网站制作 成都企业网站制作 成都h5网站建设 网站建设费用 成都网站建设 专业网站建设 成都网站建设 营销型网站建设 手机网站设计 手机网站制作 成都企业网站建设公司 定制网站设计 成都网站建设流程