Skip to content

Instantly share code, notes, and snippets.

Created Jun 16, 2022
What would you like to do?
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