vendredi 30 juin 2017

c#: " if " is working weird

i was developing my own BASIC language. When i was making IF command i got this:

object firstElement = tokens[1];
object secondElement = tokens[3];
string conditionType = tokens[2];
bool resultOfCondition = false;

if (conditionType == "==") {
    if (firstElement == secondElement) 
    {resultOfCondition = true; Console.WriteLine("DEBUG: true!");} else {resultOfCondition = false; Console.WriteLine("DEBUG: false!");}
} else if (conditionType == "!=") {

} else {
    throw new System.ArgumentException("It's not any type of contidion!", "original");
}

where

tokens[1] = 3;
tokens[3] = 3;
tokens[2] = "==";

and my console's output is really weird:

DEBUG: false!

I don't know what is going on, and why output is false! Can someone help me?

Aucun commentaire:

Enregistrer un commentaire