Created
July 16, 2015 22:53
-
-
Save Fhernd/d318a43891d7d178de2a to your computer and use it in GitHub Desktop.
Uso de palabra clave fixed en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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