I have this piece of code here. In case ServiceType.Register:
I have what appears to be two equalivenat statements one using reguarl "if" statement and one using the triany operator "?/:". The "if" statement VS reports no error. However with this line:
IsXML == true ? PopulateRegister(ParseType.Xml) : PopulateRegister(ParseType.Str);
VS is erroring out saying:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Anyone know why regular if
statement has no error but if you use "?/:" (one liner) throws an error? Pic is also attached.
switch (this.ServiceType)
{
case SerivceType.Login:
PopulateLogin();
break;
case SerivceType.Register:
if (IsXML == true)
PopulateRegister(ParseType.Xml);
else
PopulateRegister(ParseType.Str);
IsXML == true ? PopulateRegister(ParseType.Xml) : PopulateRegister(ParseType.Str);
break;
case SerivceType.Verify:
PopulateVerify();
break;
}
Aucun commentaire:
Enregistrer un commentaire