C# program to catch all the exceptions using Exception class
Program.cs
Output
kodingwindow@kw:~/csharp$ dotnet runFirst Exception: System.DivideByZeroException: Attempted to divide by zero. at Program.<Main>$(String[] args) in /home/kodingwindow/csharp/Program.cs:line 6 Second Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Program.<Main>$(String[] args) in /home/kodingwindow/csharp/Program.cs:line 13 kodingwindow@kw:~/csharp$
What Next?
C# program to demonstrate the use of nested try and catch blocks
C# program to demonstrate the use of finally blocks
C# program to handle the DivideByZeroException
Advertisement