Created
August 2, 2020 08:35
-
-
Save tafo/5526b8483c96d7643c6d876fd9a6dc1b 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 bool DetectCapitalUse(string word) | |
{ | |
var capitals = 0; | |
for (var i = 0; i < word.Length; i++) | |
{ | |
if (char.IsUpper(word[i])) capitals++; | |
} | |
if (capitals == word.Length || capitals == 0) return true; | |
return capitals == 1 && char.IsUpper(word[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment