Note: I\'ve seen this question asked sometimes before (a, b, c), but neither of these was in C#, nor helpful.
Assume I\'m using the ? : ternary
? :
I can suggest an extension method like this:
public static T ChangeOn(this T variable, bool condition, T newValue) { return condition ? newValue : variable; }
And use it like this:
var result = r.ChangeOn(r == 5, 0); //or: r = r.ChangeOn(r == 5, 0); for self change