jeudi 29 mars 2018

Visual Studio C# if statement not working in Debug

So I have a weird situation, where I get to an if statement while debugging, and I'm finding that even though EM=="M", my if statement if(EM=="E") is being entered anyway... I'm also noticing that some of my code seems to be just getting skipped over when I'm stepping though the code(F11).

I'm using C# in VS2015 and VS2017, it's having the issue in both versions. I was using Framework 4.5, I had switched it to 4.6.1 to build a compatible version for a different program. But switching that back didn't change anything...

try
{
  if (EM == "E") //If english
  {
    topText.TextString = rad + "\" minimum bend radius";
  }
  if (EM == "M") //Metric
  {
    topText.TextString = Convert.ToString(Math.Round((Convert.ToDouble(rad)) * 0.3048, 2)) + "\" minimum bend radius";
  }
}
catch (IOException e)
{
      // Extract some information from this exception, and then   
      // throw it to the parent method.  
      if (e.Source != null)
        System.Windows.Forms.MessageBox.Show("IOException source: {0}", e.Source);
      throw;
}  

If anyone else is aware of this issue or know's what I may be doing wrong, help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire