BudgetAnalyser.Engine.StringExtension.AnOrA C# (CSharp) Метод

AnOrA() публичный статический Метод

Returns the appropriate 'An' or 'A' prefix for the given string. The given string is not included in the return text.
public static AnOrA ( this instance, bool properCase = false ) : string
instance this The string to determine the prefix for.
properCase bool A boolean to indicate if the prefix should be proper-cased or not.
Результат string
        public static string AnOrA(this string instance, bool properCase = false)
        {
            if (string.IsNullOrWhiteSpace(instance))
            {
                return instance;
            }

            var useAn = Vowels.Contains(instance.ToCharArray(0, 1)[0]);

            if (properCase && useAn)
            {
                return "An";
            }

            if (properCase)
            {
                return "A";
            }

            if (useAn)
            {
                return "an";
            }

            return "a";
        }