Exception throws : Exception Throw « Language Basics « C# / C Sharp






Exception throws

Exception throws
/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/

 using System;

 namespace ExceptionHandling
 {
    public class TesterExceptionHandling1
    {

       static void Main()
       {
           Console.WriteLine("Enter Main...");
           TesterExceptionHandling1 t = new TesterExceptionHandling1();
           t.Run();
           Console.WriteLine("Exit Main...");
       }
       public void Run()
       {
           Console.WriteLine("Enter Run...");
           Func1();
           Console.WriteLine("Exit Run...");
       }

        public void Func1()
        {
            Console.WriteLine("Enter Func1...");
            Func2();
            Console.WriteLine("Exit Func1...");
        }

        public void Func2()
        {
            Console.WriteLine("Enter Func2...");
            throw new System.Exception();
            Console.WriteLine("Exit Func2...");
        }

    }
 }

           
       








Related examples in the same category

1.Throwing Your Own Exceptions
2.Intentionally throws an error to demonstrate Just-In-Time debuggingIntentionally throws an error to demonstrate
              Just-In-Time debugging
3.Exception throw and catchException throw and catch
4.Exception throw and catch 2Exception throw and catch 2
5.illustrates creating and throwing an exception objectillustrates creating and throwing an exception object
6.Demonstrates rethrowing an exception from a methodDemonstrates rethrowing an exception from a method
7.Let the C# runtime system handle the errorLet the C# runtime system handle the error
8.Manually throw an exceptionManually throw an exception
9.Rethrow an exceptionRethrow an exception