C# program to terminate the current running program explicitly
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to terminate the current running program is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a Demo class that contains the Main() method. In the Main() method we read the value of variable num and then check the value of num. If the value of num is greater than 5 then we print the message "Program terminated explicitly" and terminated the program using the Exit() method of Environment class. If the value of variable num is less than or equal to 5 then the "Finally block executed" message will be printed on the console screen.