From 11ffa438107fe9f8239e21ca177b9c7d46211f1c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 20 Apr 2020 14:17:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20string.IsUpper=20and=20string?= =?UTF-8?q?.IsLower?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - IsLower: Determines if all alpha characters in this string are considered lowercase. - IsUpper: Determines if all alpha characters in this string are considered uppercase. --- CHANGELOG.md | 4 ++++ X10D/src/StringExtensions.cs | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc64b2..df0983f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs index 0cc0dea..4743075 100644 --- a/X10D/src/StringExtensions.cs +++ b/X10D/src/StringExtensions.cs @@ -145,6 +145,28 @@ return encoding.GetBytes(str); } + /// + /// Determines if all alpha characters in this string are considered lowercase. + /// + /// The input string. + /// Returns if all alpha characters are lowercase, + /// otherwise. + public static bool IsLower(this string str) + { + return str.Where(char.IsLetter).All(char.IsLower); + } + + /// + /// Determines if all alpha characters in this string are considered uppercase. + /// + /// The input string. + /// Returns if all alpha characters are uppercase, + /// otherwise. + public static bool IsUpper(this string str) + { + return str.Where(char.IsLetter).All(char.IsUpper); + } + /// /// Generates a new random string by filling it with characters found in . ///