【发布时间】:2016-01-09 01:13:48
【问题描述】:
我正在用 C# 和 XNA 制作游戏,我想在类构造函数中使用 Texture2D 作为参数。我应该使用以下哪种方法?
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"));
如果使用另一种方法就不会出现使用一种方法的后果吗?如果是这样,首选哪种方法?或者我使用哪种方法无关紧要?
【问题讨论】:
标签: c# parameters xna arguments texture2d