因此,由于我仍然想在 12 月之前创建一个简单的吃 bean 人克隆版,我目前正在自学 C# 以便使用 XNA Game Studio 3.1,我找到了最好的答案并提供了现成的文档供学习从以及有点 future 安全。
无论如何,问题来 self 正在阅读的一本书,其中函数声明如下:
public void TransformVectorByReference()>
{
/* ...stuff... */
}
我假设内部结构并不重要,因为编译器提示函数声明中的 ´>` 符号。但是,多个函数是这样声明的,并且所有函数都抛出以下类型的错误:
; expected.
任何人都可以告诉我这个函数的作用/指向我之前的 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 );
}
最佳答案
> 是错误的,应该删除。
关于c# - '>' 函数声明期间的符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3405669/