Example of using the fixed statement : fixed : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » fixed »

 

Example of using the fixed statement








    
 

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;
            }
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» fixed