/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate pointer comparison.
using System;
public class PtrCompDemo {
unsafe public static void Main() {
int[] nums = new int[11];
int x;
// find the middle
fixed (int* start = &nums[0]) {
fixed(int* end = &nums[nums.Length-1]) {
for(x=0; start+x <= end-x; x++) ;
}
}
Console.WriteLine("Middle element is " + x);
}
}
|