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.

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