C#指针实例

            unsafe
            {

                long* a;
                int* a1 = stackalloc int[5];
                a1[0] = 1;
                a1[1] = 2;
                a1[2] = 3;
                a1[3] = 4;
                a1[4] = 5;
                a = (long*)a1;
                Console.WriteLine(*a);
                for (int i = 0; i < 2; i++)
                {
                    Console.WriteLine(*(a + i));
                    Console.WriteLine(*(a1 + i));
                }
                int[] b1 = { 10, 11, 12, 13, 14 };
                fixed (int* bb = &b1[0])
                {
                    for (int i = 0; i < 5; i++)
                    {
                        Console.WriteLine(*(bb + i));
                    }
                }

            }

posted @ 2016-09-18 15:17  聂小千  阅读(315)  评论(0编辑  收藏  举报