Created
July 14, 2013 17:05
-
-
Save Fhernd/5994948 to your computer and use it in GitHub Desktop.
Demostración del uso del operador de incremento 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
class Incremento | |
{ | |
static void Main() | |
{ | |
int c; | |
// demuestra el operador de incremento postfijo | |
c = 5; // asigna 5 a c | |
Console.WriteLine(c); // Imprime 5 | |
Console.WriteLine(c++); // Imprime 5 otra vez, luego realiza el incremento | |
Console.WriteLine(c); // Imprime 6 | |
Console.WriteLine(); // Imprime línea en blanco | |
// demuestra el operador de incremento prefijo | |
c = 5; | |
Console.WriteLine(c); // Imprime 5 | |
Console.WriteLine(++c); // Incrementa c, luego imprime 6 otra vez. | |
Console.WriteLine(c); // Imprime 6 otra vez | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment