This is an extremely poor programming practice that you're using. Conditional expressions should not have side effects; they should compute values. You are executing the side effect and then throwing away the side effect! You should either (1) make a side-effect-free version:
id = (isChar && id > 121) ? 65 : id + 1;
or (2) write your side-effecting version as statements, not expressions:
if (isChar && id > 121)
id = 65;
else
id++;
Let's take a look in more detail what is wrong with this simplified version of your original buggy code:
id = whatever ? 65 : id++;
Suppose whatever is false. What happens? id++ is morally equivalent to:
int PostIncrement(ref int x)
{
int temp = x;
x = temp + 1;
return temp;
}
So suppose you did:
id = whatever ? 65 : PostIncrement(ref id);
What happens? Suppose id is 1. You pass it by reference to PostIncrement. PostIncrement makes a copy of the value of id -- 1 -- in temp. It then adds one to that -- 2 -- and assigns the result to id. So id is now 2. Then it returns 1.
Back in the caller, id is now 2, and then you assign the result of PostIncrement, which was 1, and now id is 1 again.
Do not use id++ to mean id + 1 because that is not at all what it means.