Usage of CHAR data type in a Logical OR expression

Mini

New member
Joined
Nov 22, 2016
Messages
1
Programming Experience
5-10
Hi Everyone,

This is Mini and I am a beginner in C#.
Was trying out some code something like :


do
{

XXX...
}
while (ch != 'Y' || ch !='y');

where ch is a character data type.
The problem is with this condition the loop goes infinite and not come out when passing value = 'Y' or 'y'.
Then read that logical OR works only with int and enum. Then with implicit type cast to int I tried but the result was same

Please help and guide me how I can establish this condition.

Thanks
Mini
 
Logical OR Operator: ||
The logical OR operator (||) returns the boolean value true if either or both operands is true and returns false otherwise.
Your expression will always evaluate to true. (y!=Y and Y!=y)
 
Back
Top Bottom