• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

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?
0
Sling_Blade
Asked:
Sling_Blade
  • 3
  • 2
1 Solution
 
neilpriceCommented:
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
0
 
Sling_BladeAuthor Commented:
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.
0
 
neilpriceCommented:
Without seeing further details of your implementation I'm sorry I can't help.

Have you tried checking the type of the responseCode variable just before you make the comparison?
Set a breakpoint in your code the line before and check what it is then?

Neil
0
 
Sling_BladeAuthor Commented:

It seems to be working now!?

Thanks anyway for your fast response.

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


0
 
neilpriceCommented:
Hey no problem, happens to us all! :)

Good luck!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now