using System;
public class Empleado
{
string primerNombre;
public string PrimerNombre
{
get
{
return primerNombre;
}
set
{
primerNombre = value;
}
}
string apellido;
public string Apellido
{
get
{
return apellido;
}
set
{
apellido = value;
}
}
int edad;
public int Edad
{
get
{
return edad;
}
set
{
edad = value;
}
}
int idEmpleado;
public int IdEmpleado
{
get
{
return idEmpleado;
}
set
{
idEmpleado = value;
}
}
// Sobreescritura del método ToString
public override string ToString()
{
return String.Format("Nombre: {0}, Apellido: {1}, y Edad: {2}.", primerNombre, apellido, edad);
}
}
public class EmpleadoPrueba
{
public static void Main()
{
Empleado emp1 = new Empleado();
emp1.PrimerNombre = "Juan";
emp1.Apellido = "Ortiz";
emp1.Edad = 40;
emp1.IdEmpleado = 123456789;
Empleado emp2 = new Empleado();
emp2.PrimerNombre = "Juan";
emp2.Apellido = "Ortiz";
emp2.Edad = 40;
emp2.IdEmpleado = 123456789;
// Comparación de dos instancias de Epleado diferentes.
Console.WriteLine (emp1.Equals (emp2));
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIEVtcGxlYWRvCnsKICAgIHN0cmluZyBwcmltZXJOb21icmU7CiAgICBwdWJsaWMgc3RyaW5nIFByaW1lck5vbWJyZQogICAgewogICAgICAgIGdldAogICAgICAgIHsKICAgICAgICAgICAgcmV0dXJuIHByaW1lck5vbWJyZTsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBwcmltZXJOb21icmUgPSB2YWx1ZTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIHN0cmluZyBhcGVsbGlkbzsKICAgIHB1YmxpYyBzdHJpbmcgQXBlbGxpZG8KICAgIHsKICAgICAgICBnZXQKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybiBhcGVsbGlkbzsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBhcGVsbGlkbyA9IHZhbHVlOwogICAgICAgIH0KICAgIH0KICAgIAogICAgaW50IGVkYWQ7CiAgICBwdWJsaWMgaW50IEVkYWQKICAgIHsKICAgICAgICBnZXQKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybiBlZGFkOwogICAgICAgIH0KICAgICAgICBzZXQKICAgICAgICB7CiAgICAgICAgICAgIGVkYWQgPSB2YWx1ZTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGludCBpZEVtcGxlYWRvOwogICAgcHVibGljIGludCBJZEVtcGxlYWRvCiAgICB7CiAgICAgICAgZ2V0CiAgICAgICAgewogICAgICAgICAgICByZXR1cm4gaWRFbXBsZWFkbzsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBpZEVtcGxlYWRvID0gdmFsdWU7CiAgICAgICAgfQogICAgfQogICAgCiAgICAvLyBTb2JyZWVzY3JpdHVyYSBkZWwgbcOpdG9kbyBUb1N0cmluZwogICAgcHVibGljIG92ZXJyaWRlIHN0cmluZyBUb1N0cmluZygpCiAgICB7CiAgICAgICAgcmV0dXJuIFN0cmluZy5Gb3JtYXQoIk5vbWJyZTogezB9LCBBcGVsbGlkbzogezF9LCB5IEVkYWQ6IHsyfS4iLCBwcmltZXJOb21icmUsIGFwZWxsaWRvLCBlZGFkKTsKICAgIH0KfQoKcHVibGljIGNsYXNzIEVtcGxlYWRvUHJ1ZWJhCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKICAgICAgICBFbXBsZWFkbyBlbXAxID0gbmV3IEVtcGxlYWRvKCk7CiAgICAgICAgZW1wMS5QcmltZXJOb21icmUgPSAiSnVhbiI7CiAgICAgICAgZW1wMS5BcGVsbGlkbyA9ICJPcnRpeiI7CiAgICAgICAgZW1wMS5FZGFkID0gNDA7CiAgICAgICAgZW1wMS5JZEVtcGxlYWRvID0gMTIzNDU2Nzg5OwogICAgICAgIAogICAgICAgIEVtcGxlYWRvIGVtcDIgPSBuZXcgRW1wbGVhZG8oKTsKICAgICAgICBlbXAyLlByaW1lck5vbWJyZSA9ICJKdWFuIjsKICA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