Getting a string to only accept 0's and 1's
I don't understand what is wrong with this line of code in particular: bool result = userInput.All(c=>Char.IsLetter(c) && c=='1' && c=='0');
10 Replies
it cant be '1' and '0' at the same time
oh i see
should i make two bool results then?
or would that work
Use an or
Not an and
char is letter and (1 or 0)
oh
i'll try that rq
now that I think about it, does this strong not work in my case?
i originally had the if statement set to false, but even if I put in 0's and 1's it would still think that I put something else
is there a way to modify the bool result to only have c=='1' or c=='0'? i think the char.isLetter is the problem
i think 1 and 0 arent letters
you should remove the is lettee
would I replace the IsLetter with IsDigit in that case?
oh perfect
that was it
just is 0 or 1 is enough