Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 16, 2015 22:53
Show Gist options
  • Save Fhernd/d318a43891d7d178de2a to your computer and use it in GitHub Desktop.
Save Fhernd/d318a43891d7d178de2a to your computer and use it in GitHub Desktop.
Uso de palabra clave fixed en C#.
// OrtizOL - xCSw - http://ortizol.blogspot.com
using System;
public class Usofixed
{
int campo;
public static void Main()
{
Console.WriteLine(Environment.NewLine);
Usofixed u = new Usofixed();
// Región de código inseguro:
unsafe
{
// Obtención de puntero a partir de un tipo por valor,
// y marca región de memoria inamovible:
fixed (int* puntero = &u.campo)
{
*puntero = 9;
}
Console.WriteLine(u.campo);
}
Console.WriteLine(Environment.NewLine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment