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. |
return | 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";
}