Creata pagina "user"
This commit is contained in:
22
SteUp.Shared/Core/Utility/UtilityString.cs
Normal file
22
SteUp.Shared/Core/Utility/UtilityString.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace SteUp.Shared.Core.Utility;
|
||||
|
||||
public static class UtilityString
|
||||
{
|
||||
public static string ExtractInitials(string? fullname)
|
||||
{
|
||||
if (fullname == null) return "";
|
||||
|
||||
return string.Concat(fullname
|
||||
.Split(' ', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Take(3)
|
||||
.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[1..]
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user