Created
September 1, 2014 21:05
-
-
Save Fhernd/ad8147e36e956e16ffb5 to your computer and use it in GitHub Desktop.
Demostración de varios operadores con tipos nullable.
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
using System; | |
namespace Articulos.Cap04.TiposNullables | |
{ | |
public sealed class LiftingOperadores | |
{ | |
public static void Main() | |
{ | |
// Declaración de variables nullable: | |
int? x = 13; | |
int? y = null; | |
// Ejemplos con operadores de igualdad: | |
Console.WriteLine ("\n--- Ejemplos de Operadores de Igualdad ---\n"); | |
Console.WriteLine ("\tx == y -> {0:3}", (x == y)); // False | |
Console.WriteLine ("\tx == null -> {0}", (x == null)); // False | |
Console.WriteLine ("\tx == 13 -> {0}", (x == 13)); // True | |
Console.WriteLine ("\ty == null -> {0}", (y == null)); // True | |
Console.WriteLine ("\ty == 13 -> {0}", (y == 13)); // False | |
Console.WriteLine ("\ty != 13 -> {0}", (y != 13)); // True | |
Console.WriteLine ("\n--- Ejemplos de Operadores Relacionales ---\n"); | |
Console.WriteLine ("\tx < 17 -> {0}", (x < 17)); // True | |
Console.WriteLine ("\ty < 17 -> {0}", (y < 17)); // False | |
Console.WriteLine ("\ty > 17 -> {0}", (y > 17)); // False | |
Console.WriteLine ("\n--- Ejemplos de Otros Operadores ---\n"); | |
Console.WriteLine ("\tx + 13 -> {0}", (x + 13)); // 26 | |
Console.WriteLine ("\tx + y -> {0}", (x + y)); // null (no imprime nada) | |
Console.WriteLine (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment