C#用了C++的语法,是不是也使用了其指针的概念?

解决方案 »

  1.   

    指针是有的,但是属于不安全代码,尽量少用,操作硬件经常会用到指针
    MSDN示例:
    using System;class Point { 
       public int x, y; 
    }class FixedTest 
    {
       // unsafe method: takes pointer to int
       unsafe static void SquarePtrParam (int* p) 
       {
          *p *= *p;
       }   unsafe public static void Main() 
       {
          Point pt = new Point();
          pt.x = 5;
          pt.y = 6;
          // pin pt in place:
          fixed (int* p = &pt.x) 
          {
             SquarePtrParam (p);
          }
          // pt now unpinned
          Console.WriteLine ("{0} {1}", pt.x, pt.y);
       }
    }
      

  2.   

    有的,unsafe,即不安全代码中有.如楼上贴出来的示例.
      

  3.   

    c#里的指针属于unsafe;慎用阿
      

  4.   

    所以使用时基本都fixed,因为托管会把你的程序到处乱放