Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C# Data Types
  • C# Decision Making
  • C# Methods
  • C# Delegates
  • C# Constructors
  • C# Arrays
  • C# ArrayList
  • C# String
  • C# Tuple
  • C# Indexers
  • C# Interface
  • C# Multithreading
  • C# Exception
Open In App
Next Article:
How to Solve Class Cast Exceptions in Java?
Next article icon

C# System Level Exception vs Application Level Exception

Last Updated : 25 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In C#, exceptions are categorized into two main types based on their origin and usage, which are System-level exceptions and Application-level exceptions. Understanding the difference between these two helps in managing exceptions properly and choosing the right exception-handling approach.

System Level Exception vs Application Level Exception

Feature

System Level Exception

Application Level Exception

Origin

This is generated by the CLR or system environment.

This is defined and thrown by the application code.

Examples

NullReferenceException, OutOfMemoryException, etc.

FileNotFoundException, InvalidUserInputException, etc.

Recoverability

This is difficult or impossible to recover from.

Sometimes it is recoverable and handled by the application logic.

Handling

This is not caught unless performing cleanup before termination.

Caught in try-catch blocks, and appropriate corrective action is taken.

Purpose

It indicates serious issues with the runtime environment.

It handles business logic errors or invalid input within the application.

System-Level vs Application-Level Exception Hierarchy in C#

CSharp-Exception

System-Level Exceptions

System-level exceptions are errors that occur due to issues with the system environment, such as problems with the runtime environment or hardware-related failures. These exceptions are generated by the .NET runtime (CLR) and are often not recoverable by the application.

Key Characteristics:

  • Origin: These are generated by the Common Language Runtime (CLR) during program execution.
  • Examples:
    • DivideByZeroException: This occurs when there is an attempt to divide a number by zero.
    • NullReferenceException: This occurs when an object reference is null but is being accessed.
    • OutOfMemoryException: This occurs when the system runs out of memory.
    • StackOverflowException: This is caused by excessive recursion that fills the call stack.
    • IndexOutOfRangeException: This occurs when trying to access an invalid index in an array or collection.
  • Recovery: These exceptions usually represent system-related failures that are difficult or impossible to recover from. They sometimes lead to program termination.
  • Handling: It is generally not recommended to catch these exceptions unless you are trying to log or perform cleanup before exiting the program.

Application-Level Exceptions

Application-level exceptions, also known as custom exceptions, are errors that occurs from logical issues in the application code. These exceptions are defined by the application developer to handle specific business logic errors or invalid inputs.

Key Characteristics:

  • Origin: These are created by the developer to handle specific application logic failures or expected error conditions.
  • Examples:
    • FileNotFoundException: This can occur if the application tries to access a file that doesn’t exist.
    • InvalidUserInputException: A custom exception thrown when the user enters invalid data.
    • PaymentProcessingException: A custom exception thrown in an e-commerce application when there is an issue with payment processing.
  • Recovery: These exceptions are often recoverable and can be handled by the application logic. For example, we may ask the user to correct input or retry an operation.
  • Handling: Application-level exceptions are sometimes caught and managed by using try-catch blocks, and proper recovery or corrective actions can be taken.


Next Article
How to Solve Class Cast Exceptions in Java?

M

ManasiKirloskar
Improve
Article Tags :
  • C#
  • Difference Between
  • CSharp-Exception

Similar Reads

  • Difference between Exception::getMessage and Exception::getLine
    Exception::getMessage: The getMessage exception in PHP language is basically used by the programmers to know the Exception message. It means that whenever an exception condition occurs in a code, in order to know the exact meaning and what that exception is all about this function is been used. This
    2 min read
  • Difference Between Application Software and Operating System
    A computer can only carry out certain tasks with the help of software, which is a set of guidelines or instructions. Software can be broadly divided into two categories: system software and application software. The primary program on a computer that has direct access to the hardware of the system i
    5 min read
  • How to Solve Class Cast Exceptions in Java?
    An unexcepted, unwanted event that disturbed the normal flow of a program is called Exception. Most of the time exceptions are caused by our program and these are recoverable. Example: If our program requirement is to read data from the remote file locating at the U.S.A. At runtime, if the remote fi
    3 min read
  • Difference Between System Software and Application Software
    In the era of Digitalization and Modernization, Software is the very crucial support that allows hardware to perform various useful tasks. There are two categories of software; System Software and Application Software, these types perform different work which is why it is crucial to understand the d
    6 min read
  • Exception Handling in Distributed Systems
    Exception handling in distributed systems is crucial for maintaining reliability and resilience. This article explores strategies for managing errors across networked services, addressing challenges like fault tolerance, error detection, and recovery, to ensure seamless and robust system operation.
    12 min read
  • Difference between runtime exception and compile time exception in PHP
    The term PHP is an acronym for Hypertext Preprocessor, which is a server-side scripting language designed specifically for web development. It is open-source which means it is free to download and use. It is very simple to learn and use. The files have the extension “.php”. It is an interpreted lang
    3 min read
  • Comparison of Exception Handling in C++ and Java
    Both languages use to try, catch and throw keywords for exception handling, and their meaning is also the same in both languages. Following are the differences between Java and C++ exception handling: Java C++ Only throwable objects can be thrown as exceptions.All types can be thrown as exceptions.W
    4 min read
  • ClassNotFoundException Vs NoClassDefFoundError in Java
    Both of the exceptions that are ClassNotFoundException and NoClassDefFoundError occur when the class is not found at runtime. They are related to the Java classpath. ClassNotFoundException ClassNotFoundException occurs when you try to load a class at runtime using Class.forName() or loadClass() meth
    3 min read
  • Instruction Execution in Operating System
    Instruction execution in an operating gadget refers to the process by which the central processing unit (CPU) of a computer device carries out commands provided by means of walking applications or strategies. The operating machine plays an essential position in managing and coordinating this trainin
    3 min read
  • Difference between User Level thread and Kernel Level thread
    User-level threads are threads that are managed entirely by the user-level thread library, without any direct intervention from the operating system's kernel, whereas, Kernel-level threads are threads that are managed directly by the operating system's kernel. In this article, we will see the overvi
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences