Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement