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;
}
}
}
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;
}
}
}
可不知道具体怎么加上?请热心人帮我把代码加全好么
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.
信誉,给分。