19 lines
646 B
C#
19 lines
646 B
C#
namespace Template.Shared.Core.Utility;
|
|
|
|
public static class UtilityString
|
|
{
|
|
public static string ExtractInitials(string fullname)
|
|
{
|
|
return string.Concat(fullname
|
|
.Split(' ', StringSplitOptions.RemoveEmptyEntries)
|
|
.Select(word => char.ToUpper(word[0])));
|
|
}
|
|
|
|
public static string FirstCharToUpper(this string input) =>
|
|
input switch
|
|
{
|
|
null => throw new ArgumentNullException(nameof(input)),
|
|
"" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
|
|
_ => input[0].ToString().ToUpper() + input.Substring(1)
|
|
};
|
|
} |