using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Lists_sample { class Program { static void Main(string[] args) { Customers customer = new Customers(); customer.CustList(); Console.Read(); } } class Customers { string CustName; string CustID; string CustProdMake; string CustProdType; public Customers() { } public Customers(string CustName, string CustID, string CustProdMake, string CustProdType) { this.CustName = CustName; this.CustID = CustID; this.CustProdMake = CustProdMake; this.CustProdType = CustProdType; } public void CustList() { List<Customers> customers = new List<Customers>(); customers.Add(new Customers("Dan", "2334", "Mac", "G5 DC")); customers.Add(new Customers("Abe", "1234", "IBM", "Thinkpad R60")); customers.Add(new Customers("Sam", "1455", "Intel", "DV33")); customers.Add(new Customers("Sharon", "1356", "Lenovo", "Thinkpad T44")); customers.Add(new Customers("Gale", "1111", "Dell", "CX280")); Console.WriteLine("Current customers:"); Console.WriteLine("Name ID Product Make Product Type"); customers.ForEach(delegate(Customers c) { Console.WriteLine(String.Format("{0,-12}{1,-12}{2,-12}{3,-12}", c.CustName, c.CustID, c.CustProdMake, c.CustProdType)); }); } } }
|