lundi 1 juillet 2019

Need to check the condition if the value is `YES` or `NO`. And for the invalid values it should throw some error message

Here is the code what I have tried:

  if(!string.IsNullOrEmpty(Taskinfo.DoRollOver) &&(Taskinfo.DoRollOver != "YES" || Taskinfo.DoRollOver != "NO"))
  {
     throw new DataException("DoRollOver is not valid");
  }

But if I try to give the valid data such as YES or NO still it throws an exception.

Aucun commentaire:

Enregistrer un commentaire