# try Block

A block containing code that may throw an exception.

## What is **try Block** in C#?

**try Block** — A block containing code that may throw an exception.

```csharp
class OrderReader
{
    int ReadQuantity(string text)
    {
        try
        {
            return int.Parse(text);
        }
        catch (FormatException)
        {
            return 0;
        }
    }
}
```

Level: Journeyman · [More C# terms at this level](https://www.ask-codey.com/glossary/subjects/c-sharp/journeyman)

Updated: September 27, 2026

## In other subjects

- [try Block in Java](https://www.ask-codey.com/glossary/try-block)
- [try Block in JavaScript](https://www.ask-codey.com/glossary/try-block-javascript)

Source: https://www.ask-codey.com/glossary/try-block-c-sharp
