1

因此,由于我仍然想在 12 月之前创建一个简单的 Pac-Man 克隆,我目前正在自学 C# 以使用 XNA Game Studio 3.1,我通过现成的文档找到了最佳答案以供学习有点未来安全。

无论如何,问题来自我正在阅读的一本书,其中一个函数被声明为:

public void TransformVectorByReference()>
{
    /* ...stuff... */
}

我假设内部并不重要,因为编译器在函数声明中抱怨 ´>` 符号。但是,多个函数是这样声明的,并且它们都抛出了以下类型的错误:

; 预期的。

谁能告诉我这个函数的作用/指向我以前的 SO 问题,因为我没有通过搜索找到任何答案,因为我不知道该怎么称呼这个有趣的东西。

我从中获得此代码片段的书是 Sam 的 Microsoft XNA Game Studio 3.0。如果有人对这本书有任何其他更好的替代品,我会很高兴看到它们。

编辑:

我从三个五个函数中添加了一个示例函数,它们几乎相同,但其中一个使用了 > 关键字。然而,有人指出,这可能不是作者的错,而是这本书的制作/纠错方式。

public void TransformVectorByReference()
{
    Matrix rotationMatrix = Matrix.CreateRotationY( MathHelper.ToRadians(45.0f) );
    // Create a vector pointing the direction the camera is facing.
    Vector3 transformedReference;
    Vector3.Transform(ref cameraReference, ref rotationMatrix, out transformedReference);
    // Calculcate the position the camera is looking at.
    Vector3.Add(ref cameraPosition, ref transformedReference, out cameraTarget);
}

public void TransformVectorByReferenceAndOut()>
{   
    Matrix rotationMatrix = Matrix.CreateRotationY( MathHelper.ToRadians(45.0f) );
    // Create a vector pointing the direction the camera is facing.
    Vector3 transformedReference;
    Vector3.Transform( ref cameraReference, ref rotationMatrix, out transformedReference );
    // Calculate the position the camera is looking at.
    Vector3.Add( ref cameraPosition, ref transformedReference, out cameraTarget );
}
4

3 回答 3

14

> 是错误的,应该删除。

于 2010-08-04T12:58:10.460 回答
2

虽然我没看过这本书,但对我来说似乎是一个错字

于 2010-08-04T12:59:18.473 回答
1

语法无效,而且由于这出现在书中的多个地方,我敢打赌,这个问题与其说是作者的错字,不如说是原始标记和本书排版方式的问题。如果本书有随附的 CD 或网站,您可能能够找到更正后的代码示例。

于 2010-08-04T13:31:52.933 回答