I'm learning conditionals in C# and I get how they basically work.
A ? B : C
Where A = Boolean Condition
B = outcome when A == True
C = Outcome when A == False
My issue is more in writing a complex condition. I am trying to write:
(A == B || A == C) ? D : E
I would prefer a condition that looked more like:
A == (B || C) ? D : E
but that would only work when A, B, and C are Booleans and I'm trying to compare integers.
If there isn't a simple way to cut this down then that's okay. I've just been trying to work on making my code more efficient and easier to read.
Thanks
var passedRadioGroup = (RadioGroup)sender;
(passedRadioGroup.CheckedRadioButtonId == Resource.Id.radioButtonPass || passedRadioGroup.CheckedRadioButtonId == Resource.Id.radioButtonFail) ?
checklistItems[passedRadioGroup.Id].PassedBool = passedRadioGroup.CheckedRadioButtonId == Resource.Id.radioButtonPass :
checklistItems[passedRadioGroup.Id].PassedBool = null;
CheckedRadioButtonId is an int
radioButtonPass is an int
radioButtonFail is an int
PassedBool is a nullable bool
Essentially, If CheckedRadioButtonId equals either radioButtonPass or radioButtonFail, I want PassedBool to be set to true or false, otherwise I want it null.