Check If String Contains All “?”

前端 未结 8 1196
离开以前
离开以前 2021-01-17 11:35

How can I check if a string contains all question marks? Like this:

string input = \"????????\";

8条回答
  •  有刺的猬
    2021-01-17 12:21

    You can also try this:

    private bool CheckIfStringContainsOnlyQuestionMark(string value)
    {
        return !value.Where(a => a != '?').Select(a => true).FirstOrDefault();
    }
    

提交回复
热议问题