using System.Collections.Generic;
public string Name { get; set; }
public double PerUnitSales { get; set; }
public string Type { get; set; }
public Company(string name, double sales, string type)
public override string ToString()
return Name.PadRight(25) +
PerUnitSales.ToString("0.00 M").PadRight(10) +
Company[] compArray = new Company[5];
void LoadCompaniesIntoArray()
compNew = new Company("Chick-fil-A", 2.85, "Private");
compNew = new Company("Krispy Kreme", 2.57, "Public");
compNew = new Company("McDonald's", 2.53, "Public");
compNew = new Company("Panera Bread", 2.57, "Public");
compNew = new Company("Jason's Deli", 2.05, "Private");
List<Company> compList = new List<Company>();
void LoadCompaniesIntoList()
compNew = new Company("Chick-fil-A", 2.85, "Private");
compNew = new Company("Krispy Kreme", 2.57, "Public");
compNew = new Company("McDonald's", 2.53, "Public");
compNew = new Company("Panera Bread", 2.57, "Public");
compNew = new Company("Jason's Deli", 2.05, "Private");
LoadCompaniesIntoArray();
Console.WriteLine("\n[Array Info]\n============");
foreach (Company c in compArray)
Console.WriteLine(c.ToString());
Console.WriteLine("\n\n[List Info]\n============");
foreach (Company c in compList)
Console.WriteLine(c.ToString());
Console.WriteLine("\n============\n");
Console.WriteLine("Which type of company you would like " +
"to display (Public or Private)?");
strType = Console.ReadLine();
foreach (Company c in compList)
Console.WriteLine(c.ToString());
Console.WriteLine("\nEnd.");