catch Block

A block that handles a matching exception from its try block.

What is catch Block in C#?

catch Block — A block that handles a matching exception from its try block.

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

Level: Journeyman · More C# terms at this level

Updated

In other subjects