This method should do the trick:
public static bool AreAllCharactersSame(string s)
{
return s.Length == 0 || s.All(ch => ch == s[0]);
}
Explanation: if the string length is 0, then, of course, all characters are the same. Otherwise, the string characters are the same if they are all equal to the first.
source
share