What is the purpose of assert() in C#?While developing
an application, there are high probabilities for logical errors to occur.
During development phase, you can trap those errors using assert method.
You can include a logical condition in the assert method. If the condition evaluation returns false then the assert fails and appropriate call stack is displayed to the User. There are many overloaded versions of assert method. Here is an example to demonstrate the usage of this method: namespace
Application1 { Execute this program and enter the number as 0. Now the condition sampleNum>0 will fail. Hence you will get the following assertion failure message:
|