|
using System;
class MyClass {
public static void Main() {
TestClass Obj = new TestClass();
Obj.testFun();
}
}
class TestClass {
public unsafe void testFun() {
int x = 10;
int y = 20;
Console.WriteLine("x = " + x + " y= " + y);
swap(&x, &y);
Console.WriteLine("x = " + x + " y= " + y);
}
public unsafe void swap(int* p_x, int *p_y) {
int temp = *p_x;
*p_x = *p_y;
*p_y = temp;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.