(Texture2D) t1 = t2; Does it create a link or copy?

Quick question. (I could not find documentation about this anywhere)

When you do this:

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

Texture2D t2;
t2 = t1;

Does the link create a link or actually copy the texture?

I would like to know this, so I can take this into account when implementing related things.

+5
source share
2 answers

Texture2D is a class. Therefore, the destination will create a copy of the link - t1 and t2 will have the reference equality, i.e. Object.ReferenceEquals(t1, t2)will be true.

+5
source

This is only a reference job. No actual data is moved.

+5
source

All Articles