Skip to content

Comparing two Chars?

Aaron

Asked Dec 19, 2007, 1:34 PM EST1 answer
Share
LinkedInX

I am trying to compare two characters.  I can watch the charTemp array fill up and when it gets to the character I am comparing it to, it just bypasses it as if they are not equal.  The code is as follows.  Am I comparing them incorrectly?  Do I need to compare the decimal value or something?

EDIT: This ((char)tr.Read() == '&') which is right above it works fine. And I have initialized the char array as:

char[] charTemp = new char[50];


while (charTemp[i] != '%')
{
   charTemp[i] = (char)tr.Read();
   i++;
}

Thanks
Aaron

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Nevermind. I need to have i++ before the tr.Read() and not after.  It kept skipping over the character right before it was comparing it.
    0