Created
August 6, 2013 23:57
-
-
Save Fhernd/6170030 to your computer and use it in GitHub Desktop.
Demostración del uso de variables de tipo bool.
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 AgnioParOImpar | |
{ | |
static void Main() | |
{ | |
bool b = true; | |
// esta línea convierte de manera automática el valor de la variable b a texto | |
Console.WriteLine(b); | |
// obtiene el día del año | |
int dias = DateTime.Now.DayOfYear; | |
// cálcula el valor booleano usando aritmética modular | |
b = (dias % 2 == 0); | |
// se alterna entre falso y verdadero, dependiento de la evaluación anterior. | |
if (b) | |
{ | |
Console.WriteLine("El número de días es par."); | |
} | |
else | |
{ | |
Console.WriteLine("El número de días es impar."); | |
} | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment