Original Post
I was trying to do something weird: I have a nullable type which encapsulate a struct (MouseState), and a function that takes a MouseState by ref:
class Stuff
{
Nullable<MouseState> state = null;
private void DoSomething(ref MouseState theState)
{ ... }
public void Update()
{
if (state.HasValue)
{
DoSomething(ref state.Value);
}
}
} Of course, this code doesn't compile (you can't pass a value type which is the return value of a property as a ref to a function). The goal is obviously to avoid yet another a copy of the struct whne it's not null. Do I have any other way to do the same thing? Thanks for your help :)