1. Back To Blog

.NET interview questions: - What are system level exceptions and application level exceptions?

Exceptions that are thrown by .NET framework are called as system exceptions. These errors are non-recoverable or fatal errors like ArgumentOutOfRangeException, IndexOutOfRangeException, StackOverflowException etc.

 

Application exceptions are custom exceptions created for the application. Application exceptions are created by deriving from "ApplicationException" class as shown below. You can then create the object of the below exception and throw the same from the code and catch the same on the client side.

 

public class MyOwnException : ApplicationException

  private string messageDetails = String.Empty;

  public DateTime ErrorTimeStamp get; set;}

  public string CauseOfError get; set;}

 

  public MyOwnException()}

  public MyOwnException(string message,

    string cause, DateTime time)

 

    messageDetails = message;

    CauseOfError = cause;

    ErrorTimeStamp = time;

  }

 

  // Override the Exception.Message property.

  public override string Message

 

    get

   

      return string.Format("This is my own error message");

    }

  }

}

 

Also see following basic but important .NET interview questions video on debug directive

 

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social