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 = emp1; // referencias al mismo objeto
// Returna true dado que ambos objetos apuntan a los mismos valores del heap
Console.WriteLine (emp1.Equals (emp2));
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIEVtcGxlYWRvCnsKICAgIHN0cmluZyBwcmltZXJOb21icmU7CiAgICBwdWJsaWMgc3RyaW5nIFByaW1lck5vbWJyZQogICAgewogICAgICAgIGdldAogICAgICAgIHsKICAgICAgICAgICAgcmV0dXJuIHByaW1lck5vbWJyZTsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBwcmltZXJOb21icmUgPSB2YWx1ZTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIHN0cmluZyBhcGVsbGlkbzsKICAgIHB1YmxpYyBzdHJpbmcgQXBlbGxpZG8KICAgIHsKICAgICAgICBnZXQKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybiBhcGVsbGlkbzsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBhcGVsbGlkbyA9IHZhbHVlOwogICAgICAgIH0KICAgIH0KICAgIAogICAgaW50IGVkYWQ7CiAgICBwdWJsaWMgaW50IEVkYWQKICAgIHsKICAgICAgICBnZXQKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybiBlZGFkOwogICAgICAgIH0KICAgICAgICBzZXQKICAgICAgICB7CiAgICAgICAgICAgIGVkYWQgPSB2YWx1ZTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGludCBpZEVtcGxlYWRvOwogICAgcHVibGljIGludCBJZEVtcGxlYWRvCiAgICB7CiAgICAgICAgZ2V0CiAgICAgICAgewogICAgICAgICAgICByZXR1cm4gaWRFbXBsZWFkbzsKICAgICAgICB9CiAgICAgICAgc2V0CiAgICAgICAgewogICAgICAgICAgICBpZEVtcGxlYWRvID0gdmFsdWU7CiAgICAgICAgfQogICAgfQogICAgCiAgICAvLyBTb2JyZWVzY3JpdHVyYSBkZWwgbcOpdG9kbyBUb1N0cmluZwogICAgcHVibGljIG92ZXJyaWRlIHN0cmluZyBUb1N0cmluZygpCiAgICB7CiAgICAgICAgcmV0dXJuIFN0cmluZy5Gb3JtYXQoIk5vbWJyZTogezB9LCBBcGVsbGlkbzogezF9LCB5IEVkYWQ6IHsyfS4iLCBwcmltZXJOb21icmUsIGFwZWxsaWRvLCBlZGFkKTsKICAgIH0KfQoKcHVibGljIGNsYXNzIEVtcGxlYWRvUHJ1ZWJhCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKICAgICAgICBFbXBsZWFkbyBlbXAxID0gbmV3IEVtcGxlYWRvKCk7CiAgICAgICAgCiAgICAgICAgZW1wMS5QcmltZXJOb21icmUgPSAiSnVhbiI7CiAgICAgICAgZW1wMS5BcGVsbGlkbyA9ICJPcnRpeiI7CiAgICAgICAgZW1wMS5FZGFkID0gNDA7CiAgICAgICAgZW1wMS5JZEVtcGxlYWRvID0gMTIzNDU2Nzg5OwogICAgICAgIAogICAgICAgIEVtcGxlYWRvIGVtcDIgPSBlbXAxOyAgICAgICAgICAgLy8gcmVmZXJlbmNpYXMgYWwgbWlzbW8gb2JqZXRvCiAgICAgICAgCiAgICAgICAgLy8gUmV0dXJuYSB0cnVlIGRhZG8gcXVlIGFtYm9zIG9iamV0b3MgYXB1bnRhbiBhIGxvcyBtaXNtb3MgdmFsb3JlcyBkZWwgaGVhcAogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lIChlbXAxLkVxdWFscyAoZW1wMikpOwoJfQp9