using System.Collections.Generic;
private static Random random;
public string FirstName { get; set; }
public string LastName { get; set; }
public long PhoneNumber { get; set; }
public int Postcode { get; set; }
public float Id { get; set; }
public static void Main()
Program program = new Program();
Console.WriteLine("Please enter the number of customers: ");
var numberOfCustomers = Convert.ToInt16(Console.ReadLine());
var listOfCustomers = program.GenerateListOfCustomers(numberOfCustomers);
program.PrintListOfCustomers(listOfCustomers.OrderBy(c => c.LastName));
program.PrintListOfCustomers(listOfCustomers.OrderBy(c => c.Postcode));
public IEnumerable<Customer> GenerateListOfCustomers(int numberOfCustomers)
var result = new List<Customer>();
for (int i = 0; i < numberOfCustomers; i++)
var customer = new Customer
FirstName = GenerateName(5),
LastName = GenerateName(6),
PhoneNumber = random.Next(100000000, 999999999),
Postcode = random.Next(1000, 9999),
Id = random.Next(1000, 9999)
public static string GenerateName(int len)
string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "t", "v", "w", "x" };
string[] vowels = { "a", "e", "i", "o", "u" };
name += consonants[random.Next(consonants.Length)].ToUpper();
name += vowels[random.Next(vowels.Length)];
name += consonants[random.Next(consonants.Length)];
name += vowels[random.Next(vowels.Length)];
public void PrintListOfCustomers(IEnumerable<Customer> customers)
Console.WriteLine("First Name Last Name Phone Number Postcode Id");
foreach (var customer in customers)
Console.WriteLine("{0} {1} {2} {3} {4}", customer.FirstName, customer.LastName, customer.PhoneNumber, customer.Postcode, customer.Id);