lundi 25 mars 2019

if loop logic with OR condition implementation

I have to test a condition such that when the value of dr["QUALITY"].ToString() will not be "A" or the value of dr["QUALITY"].ToString() will not be "D" then only the if block should be executed. But the if block code is executed when the value is "A".

string test = dr["QUALITY"].ToString();
if ((!dr["QUALITY"].ToString().Equals("A")) || (!dr["QUALITY"].ToString().Equals("D")))
{
    dr["QUALITY_GRD"] = Calc_Rank(Convert.ToInt32(dr["QUALITY"].ToString()), 0);
    dr["QUALITY_PT"] = Calc_Grade(dr["QUALITY_GRD"].ToString(), 1);
}
else
{
    dr["QUALITY_GRD"] = "";
    dr["QUALITY_PT"] = "";
}

Here the if block code is executed when the value is "A". I can't understand what is the problem with the code. Please suggest. Thank You!!!

Aucun commentaire:

Enregistrer un commentaire