C# - What does the Assert() method do? Is it still useful?

后端 未结 9 1699
青春惊慌失措
青春惊慌失措 2020-12-12 10:37

I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should

9条回答
  •  一生所求
    2020-12-12 11:06

    Assert allows you to assert a condition (post or pre) applies in your code. It's a way of documenting your intentions and having the debugger inform you with a dialog if your intention is not met.

    Unlike a breakpoint, the Assert goes with your code and can be used to add additional detail about your intention.

提交回复
热议问题