What is the difference between System.Exception vs System.SystemException

Hello

In case if theres any system exception, which should i use?
System.Exception or System.SystemException
image

Thanks,
Hnasen

Hi @hansen_Lobo

I think both will give you the same exception descripton

System exception - exception occurred due to system ( web application, stand alone application etc.) Eg: application not reachable , Ui element not found etc

Mostly we use system.exception

1 Like

@hansen_Lobo

  1. System.Exception:
  • System.Exception is the base class for all exceptions in the .NET Framework.
  • It represents any runtime exception that can occur during program execution.
  • You can catch and handle exceptions of type System.Exception to capture any exception thrown in your code. However, it’s considered a best practice to catch more specific exception types whenever possible, as it allows for more targeted error handling.
  1. System.SystemException:
  • System.SystemException is a base class for system-level exceptions in the .NET Framework.
  • It is derived from System.Exception and represents exceptions that are thrown by the common language runtime (CLR) or other system-related issues.
  • Examples of exceptions derived from System.SystemException include NullReferenceException, IndexOutOfRangeException, and InvalidOperationException.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.