Link to home
Start Free TrialLog in
Avatar of Sling_Blade
Sling_BladeFlag for New Zealand

asked on

Cannot recognise variable string value in If statement

Hi,

I am trying to determine if a variable is equal to "00" but my code refuses to cooperate.

<code>
logToFile(responseCode);                       => 00
logToFile(responseCode.GetType())         => System.String

if(!(responseCode.Equals("00")))
{
    Do something....                               => it always does something (this is where I am going wrong)

}
else
{
   Do something else ...                         => never here where it should go!
}

</code>

Any ideas as to why I can't get it to recognise the value in the variable?
Avatar of neilprice
neilprice

Hi,

This makes no sense to me with the data you've provided - I copied and pasted your code to run it and it works fine for me...  

How is the variable "responseCode" defined in your code?

Neil
Avatar of Sling_Blade

ASKER

responseCode is a reference variable passed in as an object to the module that assigns its vaue.

When it returns from the module (as a System.String) I try to read its value.
ASKER CERTIFIED SOLUTION
Avatar of neilprice
neilprice

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

It seems to be working now!?

Thanks anyway for your fast response.

Apologies, I must have hit the panic button to early.


Hey no problem, happens to us all! :)

Good luck!