ace/Source/ACE.Common/Extensions/StringExtensions.cs
Mag-nus 4dab146548
Code cleanup (#1681)
* Flags attribute

* empty statement

* Fix Formatting

* Fix OrderBy -> ThenBy

* use OfType

* Replace with asingle call to Count(...)

* Replace with a single call to FirstOrDefault

* Merge cast with type check

* use String.IsNullOrEmpty

* use collections count property

* use format specifier (results in shorter loc)

* use Any() instead of Count() > 0

* revert ThenBy with comment
2019-04-10 20:48:34 -05:00

27 lines
782 B
C#

namespace ACE.Common.Extensions
{
public static class StringExtensions
{
public static bool StartsWithVowel(this string s)
{
if (string.IsNullOrEmpty(s))
return false;
char firstLetter = s.ToLower()[0];
bool isVowel = "aeiou".IndexOf(firstLetter) >= 0;
return isVowel;
}
/// <summary>
/// For objects that don't have a PropertyString.PluralName
/// </summary>
public static string Pluralize(this string name)
{
if (name.EndsWith("ch") || name.EndsWith("s") || name.EndsWith("sh") || name.EndsWith("x") || name.EndsWith("z"))
return name + "es";
else
return name + "s";
}
}
}