// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; namespace E { public interface IProduct { string Title { get; set; } string Text { get; set; } decimal Price { get; set; } } public interface IExtendedProduct : IProduct { decimal WithTaxPrice { get; set; } } public class Product : IProduct { public string Title { get; set; } public string Text { get; set; } public decimal Price { get; set; } } public class ExtendedProduct : Product, IExtendedProduct { public decimal WithTaxPrice { get; set; } } public class Program { public static void Something(IReadOnlyList data) { foreach(IProduct p in data) { Console.WriteLine(p.Title); } } public static void Main(string[] args) { List data = new List(); data.Add(new ExtendedProduct { Title = "T1", Text = "Bla bla 1", Price = 10.00m, WithTaxPrice = 12.50m }); data.Add(new ExtendedProduct { Title = "T2", Text = "Bla bla 2", Price = 20.00m, WithTaxPrice = 25.00m }); Something(data); } } }