---
title: "How to catch all exceptions in c# using try and catch?"  
description: "How to catch all exceptions in c# using try and catch?"  
author: "Anonymous User"  
published: 2013-09-24  
updated: 2013-09-24  
canonical: https://www.mindstick.com/forum/1508/how-to-catch-all-exceptions-in-c-sharp-using-try-and-catch  
category: "c#"  
tags: ["c#", "mindstick", "catch all exceptions in c#", "exception", "catch exception", "try and catch block"]  
reading_time: 1 minute  

---

# How to catch all exceptions in c# using try and catch?

I want to write some try and [catch](https://www.mindstick.com/forum/159341/how-to-use-try-and-catch-in-java-for-exception-handling-and-what-happens-when-an-exception-occurs) that catch any type or [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling)

try {

code....

}

catch (Exception ex){}

Or should it be

try {

code....

}

catch {}

?

## Replies

### Reply by Pravesh Singh

Hi JayPrakash,

Both ways are correct If you need to do something with Exception object in catch block than you should use

```
try {code....}             catch (Exception ex){}
```

and than use ex in catch block.


---

Original Source: https://www.mindstick.com/forum/1508/how-to-catch-all-exceptions-in-c-sharp-using-try-and-catch

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
