Skip to content

Commit

Permalink
Minor optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 27, 2024
1 parent b17c748 commit 228aa80
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions NetAF/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public static bool IsVowel(this string value)
if (value.Length != 1)
return false;

var vowels = new[] { "A", "E", "I", "O", "U" };
return Array.Exists(vowels, x => x.InsensitiveEquals(value));
return value[0] is 'A' or 'a' or 'E' or 'e' or 'I' or 'i' or 'O' or 'o' or 'U' or 'u';
}

/// <summary>
Expand Down Expand Up @@ -155,8 +154,8 @@ public static string ToSentenceCase(this string value)
if (value.Length == 1)
return value.ToUpper();

var first = value.Substring(0, 1).ToUpper();
var rest = value.Substring(1, value.Length - 1);
var first = value[..1].ToUpper();
var rest = value[1..];

return $"{first}{rest}";
}
Expand Down

0 comments on commit 228aa80

Please sign in to comment.