jordan weitz1,423 Points
invader.Location = location;
ok so this is mad confusing for me. The code in the title is using the Location method from the invader class. He doesn't specify whether or not we are using the "Get" or "Set" though, just that we are using Location. I think this can be done because in the code above we are effectively setting the value so perhaps c# can assume we are using the "Set" method. However, directly proceeding this we flip this code around "location = invader.Location;" and this is supposed to be referencing the "Get" method I assume. How does the console or whatever know that this is for the "Get" method? for example if I declare that x = 5, isn't that the same as if i declare 5 = x?
Steven Parker138,173 Points
A single equal sign is an assignment operator, and assignments always work right-to-left, evaluating the term on the right, and storing it where the term on the left specifies it should go.
So any property on the right side will be accessed with the "get" method, and one on the left side will be accessed using the "set" method.
And assuming "x" is a variable of an appropriate type, "
x = 5" is a valid assignment, but "
5 = x" is not, since you can't change the value of a literal number 5.