Csharp/C Sharp/Language Basics/fixed — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 14:39, 26 мая 2010

Example of using the fixed statement

<source lang="csharp"> using System; public class Starter {

   private static int[] numbers = { 5, 10, 15, 20, 25, 30 };
   public unsafe static void Main() {
       int count = 0;
       Console.WriteLine(" Pointer Value\n");
       fixed (int* pI = numbers) {
           foreach (int a in numbers) {
               Console.WriteLine("{0} : {1}",
                   (int)(pI + count), *((int*)pI + count));
               ++count;
           }
       }
   }

}

</source>