Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. using System;
  4.  
  5. public class Usofixed
  6. {
  7.     int campo;
  8.    
  9.     public static void Main()
  10.     {
  11.         Console.WriteLine(Environment.NewLine);
  12.        
  13.         Usofixed u = new Usofixed();
  14.        
  15.         // Región de código inseguro:
  16.         unsafe
  17.         {
  18.             // Obtención de puntero a partir de un tipo por valor,
  19.             // y marca región de memoria inamovible:
  20.             fixed (int* puntero = &u.campo)
  21.             {
  22.                 *puntero = 9;
  23.             }
  24.            
  25.             Console.WriteLine(u.campo);
  26.         }
  27.        
  28.         Console.WriteLine(Environment.NewLine);
  29.     }
  30. }