"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
If I do this, i get complaints saying that || cannot be used for char
and bool. Any help?
[...]
} while ( ch== 'a' || ch = 'A' || ch == 'b' || ch = 'B' || ch
== 'c' || ch = 'C' || ch == 'e' || ch = 'E');
You are missing an equals sign in a few of your tests. The compiler
evaluates the expression as type "char" which is not a valid type for the
boolean test.
For what it's worth, this sort of test can be handled more efficiently, and
in an easier-to-write manner, by comparing the character as a range instead
of testing for all possibilities.
For example:
while (Char.ToLower(ch) >= 'a' && Char.ToLower(ch) <= 'e');
As an added benefit, it's much harder to leave out an important character in
the comparison when you do it this way. :)
One last tip: one of the first things I do when I get a compiler error that
I can't immediately figure out is to look very carefully at the line of code
generating the error. I mean, more carefully than I was already.
Non-obvious problems often turn out to be simple typographical errors such
as the one you've got here. But once you've written the code, it takes some
very thorough inspection to find the problem...your brain knows what you
meant to write, and will keep telling you the line is correct, hiding the
error from you unless you go very slowly.
Of course, sometimes it's good just to get someone else to look at the code.
Since they didn't write it, the error will be more obvious to them. But I'd
say that a public newsgroup isn't the best place to get help with syntax
errors. :) IMHO, it's better for the newsgroup to teach how to fish, than
to hand out fish. :)
Pete