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 ( "\t x == y -> {0:3}" , ( x == y) ) ; // False
Console.WriteLine ( "\t x == null -> {0}" , ( x == null ) ) ; // False
Console.WriteLine ( "\t x == 13 -> {0}" , ( x == 13 ) ) ; // True
Console.WriteLine ( "\t y == null -> {0}" , ( y == null ) ) ; // True
Console.WriteLine ( "\t y == 13 -> {0}" , ( y == 13 ) ) ; // False
Console.WriteLine ( "\t y != 13 -> {0}" , ( y != 13 ) ) ; // True
Console.WriteLine ( "\n --- Ejemplos de Operadores Relacionales ---\n " ) ;
Console.WriteLine ( "\t x < 17 -> {0}" , ( x < 17 ) ) ; // True
Console.WriteLine ( "\t y < 17 -> {0}" , ( y < 17 ) ) ; // False
Console.WriteLine ( "\t y > 17 -> {0}" , ( y > 17 ) ) ; // False
Console.WriteLine ( "\n --- Ejemplos de Otros Operadores ---\n " ) ;
Console.WriteLine ( "\t x + 13 -> {0}" , ( x + 13 ) ) ; // 26
Console.WriteLine ( "\t x + y -> {0}" , ( x + y) ) ; // null (no imprime nada)
Console.WriteLine ( ) ;
}
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIEFydGljdWxvcy5DYXAwNC5UaXBvc051bGxhYmxlcwp7CiAgICBwdWJsaWMgc2VhbGVkIGNsYXNzIExpZnRpbmdPcGVyYWRvcmVzCiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQogICAgICAgIHsKICAgICAgICAgICAgLy8gRGVjbGFyYWNpw7NuIGRlIHZhcmlhYmxlcyBudWxsYWJsZToKICAgICAgICAgICAgaW50PyB4ID0gMTM7CiAgICAgICAgICAgIGludD8geSA9IG51bGw7CiAgICAgICAgICAgIAogICAgICAgIC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H0iLCAoeSA8IDE3KSk7ICAgICAgICAgICAgLy8gRmFsc2UKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUgKCJcdHkgPiAxNyAtPiB7MH0iLCAoeSA+IDE3KSk7ICAgICAgICAgICAgLy8gRmFsc2UKICAgICAgICAgICAgCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiXG4tLS0gRWplbXBsb3MgZGUgT3Ryb3MgT3BlcmFkb3JlcyAtLS1cbiIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSAoIlx0eCArIDEzIC0+IHswfSIsICh4ICsgMTMpKTsgICAgICAgICAgICAvLyAyNgogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSAoIlx0eCArIHkgLT4gezB9IiwgKHggKyB5KSk7ICAgICAgICAgICAgICAgIC8vIG51bGwgKG5vIGltcHJpbWUgbmFkYSkKICAgICAgICAgICAgCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgpOwogICAgICAgIH0KICAgIH0KfQ==