You can’t test multiple values this way, you have to specify the test value each time:
CssClass =
(idee.IdTypeEtatIdee == (int)EnumTypeEtatIdee.example? "example" :
(idee.IdTypeEtatIdee == (int)EnumTypeEtatIdee.exampletwo ? "Aletude" :
(idee.IdTypeEtatIdee == (int)EnumTypeEtatIdee.examplethree? "Encours" :
(idee.IdTypeEtatIdee == (int)EnumTypeEtatIdee.examplefour ? "examplefour " :
(idee.IdTypeEtatIdee == (int)EnumTypeEtatIdee.examplefive ? "examplefive " : "null")))))
You could instead use a switch
to accomplish the same thing
var CssClass = "null";
switch((EnumTypeEtatIdee)idee.IdTypeEtatIdee){
case EnumTypeEtatIdee.example:
CssClass = "example";
break;
case EnumTypeEtatIdee.exampletwo:
CssClass = "Aletude";
break;
case EnumTypeEtatIdee.examplethree:
CssClass = "Encours";
break;
case EnumTypeEtatIdee.examplefour:
CssClass = "examplefour";
break;
case EnumTypeEtatIdee.examplefive:
CssClass = "examplefive";
break;
}
Or a dictionary:
var myDict = new Dictionary<EnumTypeEtatIdee, string>(){
{EnumTypeEtatIdee.example, "example"},
{EnumTypeEtatIdee.exampletwo, "Aletude"},
{EnumTypeEtatIdee.examplethree, "Encours"},
{EnumTypeEtatIdee.examplefour, "examplefour"},
{EnumTypeEtatIdee.examplefive, "examplefive"},
};
var CssClass = "null";
if (myDict.ContainsKey((EnumTypeEtatIdee)idee.IdTypeEtatIdee)){
CssClass = myDict[(EnumTypeEtatIdee)idee.IdTypeEtatIdee];
}
solved My code return cannot implicitly convert int to bool