在c#中使用" - >"?

Pet*_*etr 2 c# syntax

我记得我在C#中看过" - >".显然我不能通过谷歌搜索它(我不知道名字是什么).因此,如果你能向我解释,我会很高兴.谢谢.

rah*_*hul 19

-> 通过指针访问结构的成员.

请参阅- >运算符

指针类型

using System;
struct Point
{
   public int x, y; 
}

class Test 
{
   public unsafe static void Main() 
   {
      Point pt = new Point();
      Point* pp = &pt;
      pp->x = 123;
      pp->y = 456;
      Console.WriteLine ( "{0} {1}", pt.x, pt.y );
   }
}
Run Code Online (Sandbox Code Playgroud)

输出

123 456
Run Code Online (Sandbox Code Playgroud)