using System;
using System.Collections.Generic;
using System.Text;namespace Hello_Word
{
    class Program
    {
        static void Main(string[] args)
        {
            int num2 = 14000;
            int * p;
            p = &num2;
            Test(*p);
            Console.WriteLine("num2="+num2);
        }         static void Test(int *pp)
        {
            *pp = 400;
        }
    }    
}

解决方案 »

  1.   

    我知道该用unsafe
    可不知道具体怎么加上?请热心人帮我把代码加全好么
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace Hello_Word
    {
        class Program
        {
            static unsafe void Main(string[] args)
            {
                int num2 = 14000;
                int * p;
                p = &num2;
                Test(*p);
                Console.WriteLine("num2="+num2);
            }         static unsafe void Test(int *pp)
            {
                *pp = 400;
            }
        }    
    }
    然后在工程那地方右键属性,找到允许不安全代码那地方打勾,然后就可以了
    友情提示,.net里不要这么使用指针,而应该用ref.
    信誉,给分。
      

  3.   

    一直都不知道.NET还有指针啊.....REF也不知道为何物.....哎,看来我的路还很长啊...