Entradas

Mostrando las entradas etiquetadas como interface

Caso practico por que usar una Interfaz

a causa del post anterior Cannot serialize member 'Objects' of type 'System.Collections.Generic.IList`1.... varios me preguntaron por que usar Ilist y no List directamente. Bueno aquí un pequeño y muy cotidiano ejemplo, que sirve para entender las gracias de las interfaces. Supongamos que tenemos 2 clases una llamada "auto" y otra "camion" y ambas tienen un numero de patente. y en algún reporte o pantalla solo tenemos que listar solo la Patente seria de la siguiente forma. public interface IPatentable { String Patente { set; get; } } public class Auto:IPatentable { public String Patente { set; get; } public Int32 CantidadDePuertas { set; get; } } public class Camion:IPatentable { public String Patente { set; get; } public Int64 Peso { set; get; } } y después en un objeto Dao , para rescatar los datos desde algún origen, ya sea base de datos, webservice, etc.: public IList<IPatentable> GetPAtentes() { var auto1 = new Aut...