'>'函数声明期间的符号?

IAE*_*IAE 1 c# syntax xna xna-3.0

因为我仍然希望在12月之前创建一个简单的吃豆人克隆,我现在正在教自己C#以便使用XNA Game Studio 3.1,我找到了最好的答案,并提供了现成的文档来学习因为有点未来安全.

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

public void TransformVectorByReference()>
{
    /* ...stuff... */
}
Run Code Online (Sandbox Code Playgroud)

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

; 预期.

有人能告诉我这个功能是做什么的/指向我以前的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 );
}
Run Code Online (Sandbox Code Playgroud)

Gar*_*ary 14

>是错误的,应该删除.

  • 它是无效的语法,因为编译器告诉你:)不一定是作者的错,但它至少是草率的编辑. (4认同)