views:

27

answers:

1

Is it possible to maintain a reference to a value type so that when changes are made to it my code can see them?

Example: i am building a 2D camera for XNA and i want to be able to give it a reference to an arbitrary vector2 so that i don't have to have a special interface or something that everything has to implement. Is this possible?

+1  A: 

You cannot do this. ValueTypes are not stores on the heap in .NET, so the only (practical) way to keep a reference is to put them inside of a reference type.

Usually you just keep a reference to the object containing or managing the Vector2, so that the Camera could read it as needed.

Reed Copsey