Add string.IsUpper and string.IsLower

- IsLower:
Determines if all alpha characters in this string are considered
lowercase.

- IsUpper:
Determines if all alpha characters in this string are considered
uppercase.
This commit is contained in:
Oliver Booth 2020-04-20 14:17:55 +01:00
parent 72f9474e1c
commit 11ffa43810
No known key found for this signature in database
GPG Key ID: 0D7F2EF1C8D2B9C0
2 changed files with 26 additions and 0 deletions

View File

@ -4,6 +4,10 @@
### Added
- Add `string.ChangeEncoding(Encoding, Encoding)`
- Converts this string from one encoding to another
- Add `string.IsLower`
- Determines if all alpha characters in this string are considered lowercase
- Add `string.IsUpper`
- Determines if all alpha characters in this string are considered uppercase
### Changed
- n/a

View File

@ -145,6 +145,28 @@
return encoding.GetBytes(str);
}
/// <summary>
/// Determines if all alpha characters in this string are considered lowercase.
/// </summary>
/// <param name="str">The input string.</param>
/// <returns>Returns <see langword="true"/> if all alpha characters are lowercase, <see langword="false"/>
/// otherwise.</returns>
public static bool IsLower(this string str)
{
return str.Where(char.IsLetter).All(char.IsLower);
}
/// <summary>
/// Determines if all alpha characters in this string are considered uppercase.
/// </summary>
/// <param name="str">The input string.</param>
/// <returns>Returns <see langword="true"/> if all alpha characters are uppercase, <see langword="false"/>
/// otherwise.</returns>
public static bool IsUpper(this string str)
{
return str.Where(char.IsLetter).All(char.IsUpper);
}
/// <summary>
/// Generates a new random string by filling it with characters found in <see cref="str"/>.
/// </summary>