Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created August 6, 2013 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/6170030 to your computer and use it in GitHub Desktop.
Save Fhernd/6170030 to your computer and use it in GitHub Desktop.
Demostración del uso de variables de tipo bool.
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