lundi 22 février 2016

Is there an official style guideline for throwing exception in conditional statements in C# [on hold]

I was wondering if there is an officially recommended style (by MS) for C# for throwing exceptions and conditional statements:

    private int Method1(string param)
    {
        if (IsValid(param))
        {
            return 5;
        }

        throw new ApplicationException();
    }

    private int Method2(string param)
    {
        if (!IsValid(param))
        {
            throw new ApplicationException();
        }

        return 5;
    }

Aucun commentaire:

Enregistrer un commentaire