This commit is contained in:
2025-06-24 10:56:02 +02:00
parent a97df74ef4
commit 10c1435dba
35 changed files with 509 additions and 185 deletions

View File

@@ -1,4 +1,6 @@
namespace Template.Shared.Core.Utility;
using System.Globalization;
namespace Template.Shared.Core.Utility;
public static class UtilityString
{
@@ -15,6 +17,22 @@ public static class UtilityString
{
null => throw new ArgumentNullException(nameof(input)),
"" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
_ => input[0].ToString().ToUpper() + input.Substring(1)
_ => input[0].ToString().ToUpper() + input[1..]
};
public static (string Upper, string Lower, string SentenceCase, string TitleCase) FormatString(string input)
{
if (string.IsNullOrWhiteSpace(input))
return (string.Empty, string.Empty, string.Empty, string.Empty);
var upper = input.ToUpper();
var lower = input.ToLower();
var sentenceCase = char.ToUpper(lower[0]) + lower[1..];
var textInfo = CultureInfo.CurrentCulture.TextInfo;
var titleCase = textInfo.ToTitleCase(lower);
return (upper, lower, sentenceCase, titleCase);
}
}