I'm making a game in C# and XNA and I want to use a Texture2D as a parameter in a class constructor. Which of the following methods should I use?
1.
//Load the texture as a variable and then pass it
Texture2D myTexture = Content.Load<Texture2D>("MyTexture");
MyClass myClass = new MyClass(myTexture);
2.
//Pass the loading code without storing it in a variable
MyClass myClass = new MyClass(Content.Load<Texture2D>("MyTexture"));
Are there consequences of using one method that wouldn't occur if using the other? If so, which method is preferred? Or does it not matter which method I use?
There is really no difference if you don't happen to have to do anything with the asset before passing it to the container. I would prefer method 1. though for better readability.