using System;
namespace arrayDemo
{
class Program
{
unsafe static void Main(string[] args)
{
int[] arr={10,20,30,40};
//ptr is pointer to array of integer
fixed (int* ptr = arr)
{
int* p = ptr;
for (int i =0; i<arr.Length ;i++)
{
Console.Write("{0} ",*p);
p++;
}
}
Console.ReadKey();
}
}
}
Output:
10 20 30 40
No comments:
Post a Comment