c# 指针
2020-12-27 21:27
标签:app com line static class ati print 指针变量 tty public static unsafe void swap(int a,int b) Console.WriteLine("a:" + a + ",b:" + b); Console.WriteLine("after swap:a:" + a + ",b:" + b); swapP(pa, pb); Console.WriteLine("after swapP:a:" + a + ",b:" + b); Console.ReadKey(); a:10,b:20 c# 指针 标签:app com line static class ati print 指针变量 tty 原文地址:https://www.cnblogs.com/guomengkai/p/13339454.html指针变量声明:
例:int* p1, p2, p3;
{
int temp;
temp = a;
a = b;
b = a;
}
public static unsafe void swapP(int* pa,int* pb)
{
int temp = *pa;
*pa = *pb;
*pb = temp;
}
private static unsafe void Main(string[] args)
{
int a = 10, b = 20;
swap(a, b);
int* pa = &a, pb = &b;
}
after swap:a:10,b:20
after swapP:a:20,b:10
上一篇:C#4.0