Created
March 1, 2014 21:27
-
-
Save Fhernd/9297669 to your computer and use it in GitHub Desktop.
Demostración de la operación Boxing 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
public class BoxingPrueba | |
{ | |
public static void Main() | |
{ | |
int i = 123; | |
// La operación copia el valor de i dentro del objeto object | |
object o = i; | |
// Asignamos otro valor a la variable entera i | |
i = 456; | |
// Presentamos los valores en pantall | |
// Observaremos que las variables i y o almacenan valores diferentes. | |
Console.WriteLine ("El valor del tipo por valor es: {0}.", i); | |
Console.WriteLine ("El valor del tipo por referencia es: {0}.", o); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment