【发布时间】:2014-08-15 04:21:09
【问题描述】:
这段代码中“new[] {}”是什么意思?
public Cube(Game game) : base(game)
{
vertices = Buffer.Vertex.New(
game.GraphicsDevice,
new[]
{
new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),
new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.OrangeRed),
});
}
【问题讨论】:
-
这是一个对象初始化的例子。它声明了一个长度为 2 的新数组
VertexPositionColor,并通过调用new VertexPositionColor来初始化这两个元素。
标签: c#