How can I check if a string contains all question marks? Like this:
string input = \"????????\";
Not very readable... But a regular expression is another way to do it (and it's fast):
// Looking for a string composed only by one or more "?":
bool allQuestionMarks = Regex.IsMatch(input, "^\?+$");
You can also try this:
private bool CheckIfStringContainsOnlyQuestionMark(string value)
{
return !value.Where(a => a != '?').Select(a => true).FirstOrDefault();
}