Possible Duplicate:
Benefits of using the conditional ?: (ternary) operator
hi, I’m viewing this freesource library and I saw this weird – at least for me – syntax
*currFrame = ( ( diff >= differenceThreshold ) || ( diff <= differenceThresholdNeg ) ) ? (byte) 255 : (byte) 0;
currFrame is of type byte
diff, differenceThreshold and differenceThresholdNeg are of type Int.
What does the question mark do ? , what is this weird assign sentence suppose to mean ?
Thanks in advance
The conditional operator (?:) returns one of two values depending on the value of a Boolean expression. Following is the syntax for the conditional operator.
C# reference: http://msdn.microsoft.com/en-us/library/ty67wk28.aspx
In your case currFrame will be assigned a value of 255 if
( diff >= differenceThreshold ) || ( diff <= differenceThresholdNeg )istrue, otherwise value 0 will be assigned.