Reputation: 1067
this is obviously a noob question but in XNA is ...
Vector2 a;
Vector2 b;
a = b;
under any circumstances the same as:
a.X = b.X;
a.Y = b.Y;
?
Upvotes: 1
Views: 427
Reputation: 13022
Vector2
is a struct
(which is a value type).
So, if you do a = b
.
It means it copies the memory of b
into a
. It is equivalent to:
a.X = b.X;
a.Y = b.Y;
So, if you do:
b = new Vector2(1, 2);
a = b;
b.X = 5;
Console.WriteLine("a.X = {0}, a.Y = {1}", a);
Console.WriteLine("b.X = {0}, b.Y = {1}", b);
The result is:
a.X = 1, a.Y = 2
b.X = 5, b.Y = 2
Upvotes: 3