C# FAQ: What are the differences between CSharp and Java exceptions

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

What are the differences between C# and Java exceptions?

C# and Java exceptions have many similarities. In both languages:

  • exceptions are derived from the Exception class,
  • try block to delineate guarded regions,
  • catch block to handle exceptions,
  • finally block to facilitate releasing resources,
  • exceptions can be caught and rethrown after some error handling,
  • exceptions can be wrapped inside each other when the caught exception differs from the rethrown one.

Despite the fact that exceptions in both languages support methods for creating a stack trace, only Java exceptions can alter a stack trace.

See also


Personal tools