1: public class credito:IEquatable<credito>
2: {
3: public Decimal credito_id { get; set; }
4: public String vendedor_id { get; set; }
5: public String estado { get; set; }
6: public String cliente_id { get; set; }
7: public String nombre { get; set; }
8: public String apellido { get; set; }
9: public DateTime fecha_nac { get; set; }
10: public String direccion_domicilio { get; set; }
11: public String telefono_domicilio { get; set; }
12: public Double numero_cuotas { get; set; }
13: public String cedula_conyuge { get; set; }
14: public String nombre_conyuge { get; set; }
15: public String observacion { get; set; }
16: public String email { get; set; }
17: public Int64 cotizacion_id { get; set; }
18: /// <summary>
19: /// Permite realizar comparaciones del objeto de este tipo
20: /// desarrollado por Patricio Rosado
21: /// </summary>
22: /// <param name="other"></param>
23: /// <returns></returns>
24: public bool Equals(credito other)
25: {
26: //Se Obtienen la lista de propiedades de los objetos para compararlos uno a uno.
27: PropertyInfo [] prop1 =GetType().GetProperties();
28: PropertyInfo [] prop2 =GetType().GetProperties();
29: for (int i = 0; i < prop1.Length; i++)
30: {
31: // en caso de que ninguno de las dos propiedades no sean nulas, se comparan.
32: if (prop1[i].GetValue(this, null) != null && prop2[i].GetValue(other, null) != null)
33: {
34: if (!prop1[i].GetValue(this, null).Equals(prop2[i].GetValue(other, null)))
35: return false;
36: }
37: else
38: {
39: //Caso contrario se revisa que los dos estén nulos, si uno de los dos no es nulo
40: //Se retorna False.
41: if (prop1[i].GetValue(this, null) == null && prop2[i].GetValue(other, null) != null)
42: return false;
43: if (prop1[i].GetValue(this, null) != null && prop2[i].GetValue(other, null) == null)
44: return false;
45: }
46: }
47: return true;
48: }
49: }
no olvidar hacer un using System.Reflection;