Created
July 16, 2015 22:53
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