-
-
Save lgolubyev/4ffb8567475dcfc874db19f752c858bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<string> CapitalizeFirstLetter(IEnumerable<string> enumerable) | |
{ | |
if (!enumerable.Any()) | |
{ | |
throw new ArgumentException("The sequence is empty."); | |
} | |
return enumerable.Select(CapitalizeFirstLetterLocal); | |
static string CapitalizeFirstLetterLocal(string input) => | |
input switch | |
{ | |
null or "" => throw new ArgumentNullException(nameof(input)), | |
_ => string.Concat(input[0].ToString().ToUpper(), input.AsSpan(1)) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment