Sometimes operations do change variables. Sometimes they don't. Generally operations that involve an = symbol do change a variable, but not always
You can get C# to help you out by putting the operation on a line on its own. If you get an error saying "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement" then the operation didn't change the variable
For example:
int x = 0;
x++; //operation, doesn't involve =, does change variable
x is now 1
bool b = false;
!b; //not a statement; gives an error
Calling !b doesn't flip the value of b from false to true. It takes the false that b is and converts that false to true but that in itself doesn't affect the value of b.
If an operation did affect variable values that it touched, things would go crazy, and C# would be fairly unusable. Just imagine if doing an add changed a number variable:
int age = 20;
Console.WriteLine("Next year you will be " + (age+1));
If doing
(age+1)
caused age to increment by 1, things would be very difficult to use because every time we did something like that print out we would have to remember to subtract to counteract the add.. and some things can't be undone - squaring a negative number for example
Side note, because assignment operations in C# usually return the value that was assigned to the variable, this is actually legal C# that would print your age next year and would actually also change the age variable:
int age = 20;
Console.WriteLine("Next year you will be " + (age+=1));
Try to avoid this when you're newbie
---
More examples, this time that do involve equals signs:
This is same as before, x is 1
bool b;
b != true; //also not a statement, gives an error
b ^= true; //this one does work
b ^= true
does work to flip b from false to true because it is short hand for
b = b ^ true
which is an exclusive-or op (returns false when both operands are true)
Not wishing to get too deep into this but there are other situations where you can do something but you have to capture the returned value to see a permanent change. Here are two examples, one that will and one that won't work:
int a = new int[]{3,1,2};
Array.Sort(a);
//a is now changed to be 1,2,3
string s = "Hello world";
s.Replace("Hello", "Goodbye");
//s still says "Hello world"; Replace() returned us a new string saying "Goodbye world" but we didn't capture it
s = s.Replace("Hello", "Goodbye");
//s now says Goodbye world
Remember what I said about involving an =...
..and if your operation doesn't involve an =, put it on a line on its own and see if there is an error. If there is then that statement will not change the variable on its own