|
using System;
class MyClass {
public static void Main() {
TestClass Obj = new TestClass();
unsafe {
int x = 10;
int y = 20;
Console.WriteLine("Before swap x = " + x + " y= " + y);
Obj.swap(&x, &y);
Console.WriteLine("After swap x = " + x + " y= " + y);
}
}
}
class TestClass {
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.