Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Texture2D) t1 = t2; Does it creates reference or a copy?

Quick question. (I was not able to find documentation about this anywhere)

When you do this:

Texture2D t1;
t1 = content.Load<Texture2D>("some texture");

Texture2D t2;
t2 = t1;

Does it creates a reference or actually copies the texture?

I would like to know it so I can take it into account when implementing related stuff.

like image 792
NewProger Avatar asked Sep 17 '12 16:09

NewProger


1 Answers

Texture2D is a class. Hence, assignment will create a copy of the reference - t1 and t2 will have referential equality, ie Object.ReferenceEquals(t1, t2) will be true.

like image 121
Rich O'Kelly Avatar answered Oct 08 '22 23:10

Rich O'Kelly