V
VMI
I have a really simple IF statement that looks like this:
if (sNewString.Length == iCount)
{
MessageBox.Show (sNewString.Length.ToString() + " is equal to " +
iCount.ToString() + "*" + sNewString + "*");
}
if (sNewString.Trim() == "")
{
MessageBox.Show ("");
}
if (sNewString.Length == 0)
{
MessageBox.Show ("Length equals 0");
}
if (sNewString == null)
{
MessageBox.Show ("NULL");
}
if (sNewString.Length<iCount)
{
MessageBox.Show ("sNewString.Length<iCount");
}
if (sNewString.Length>iCount)
{
MessageBox.Show ("sNewString.Length>iCount");
}
When the debugger reaches the first IF, the debugger shows that
sNewString.Length = 0, iCount = 1, and sNewString = "". The frustrating
thing is that it only enters the first IF ("sNewString.Length == iCount")
and the MessageBox displays "1 is equal to 1*" at exactly the same time the
debugger's showing that sNewString.Length = 0 and iCount = 1. How can this
be possible? The messagebox and the debugger are showing different
information. I did notice that the MessageBox didn't display the last '*'
(anything after this instance of sNewString is truncated) but I have another
IF statement that checks for NULL but it never enters that IF.
The only thing I can think of is that, before these comparisons, I convert
this specific char into a string (the byte value of this specific char is
equal to 0) so I can do the IF comparisons. But that's it.
Any information is really appreciated.
if (sNewString.Length == iCount)
{
MessageBox.Show (sNewString.Length.ToString() + " is equal to " +
iCount.ToString() + "*" + sNewString + "*");
}
if (sNewString.Trim() == "")
{
MessageBox.Show ("");
}
if (sNewString.Length == 0)
{
MessageBox.Show ("Length equals 0");
}
if (sNewString == null)
{
MessageBox.Show ("NULL");
}
if (sNewString.Length<iCount)
{
MessageBox.Show ("sNewString.Length<iCount");
}
if (sNewString.Length>iCount)
{
MessageBox.Show ("sNewString.Length>iCount");
}
When the debugger reaches the first IF, the debugger shows that
sNewString.Length = 0, iCount = 1, and sNewString = "". The frustrating
thing is that it only enters the first IF ("sNewString.Length == iCount")
and the MessageBox displays "1 is equal to 1*" at exactly the same time the
debugger's showing that sNewString.Length = 0 and iCount = 1. How can this
be possible? The messagebox and the debugger are showing different
information. I did notice that the MessageBox didn't display the last '*'
(anything after this instance of sNewString is truncated) but I have another
IF statement that checks for NULL but it never enters that IF.
The only thing I can think of is that, before these comparisons, I convert
this specific char into a string (the byte value of this specific char is
equal to 0) so I can do the IF comparisons. But that's it.
Any information is really appreciated.