public static void Main(string[] args)
Customer[] custArray = new Customer[3];
custArray[0] = new Customer() { FirstName = "Joe", LastName = "Smith", Orders = new Order[2] };
custArray[0].Orders[0] = new Order() { Price = 19.99M, Quantity = 1 };
custArray[1] = new Customer() { FirstName = "Joe", LastName = "Smith", Orders = new Order[2] };
custArray[1].Orders[0] = new Order() { Price = 19.99M, Quantity = 2 };
Console.WriteLine("*********************************************************");
foreach (var customer in custArray)
if (customer == null) continue;
Console.WriteLine("Customers with Orders ");
Console.WriteLine("{0} {1}", customer.FirstName, customer.LastName);
Console.WriteLine("*************** Orders **************");
foreach (var order in customer.Orders)
if (order == null) continue;
Console.WriteLine("{0} - {1} ", order.Price, order.Quantity);
Console.WriteLine("\n\n");
TextWriter oldOut = Console.Out;
ostrm = new FileStream("./Redirect.txt", FileMode.OpenOrCreate, FileAccess.Write);
writer = new StreamWriter(ostrm);
Console.WriteLine("Cannot open Redirect.txt for writing");
Console.WriteLine(e.Message);
Console.WriteLine("This is a line of text");
Console.WriteLine("Everything written to Console.Write() or");
Console.WriteLine("Console.WriteLine() will be written to a file");
Console.WriteLine("Done");
Motorcycle motor = new Motorcycle();
Automobile auto = new Automobile();
public string Description { get; set; }
public decimal HorsePower { get; set; }
public decimal Price { get; set; }
public virtual void CargoCapacity()
Console.WriteLine("The Cargo Capacity");
class Motorcycle : Vehicle
public override void CargoCapacity()
cargoCapacity = (PI * (radius * radius) * height) * 2;
Console.WriteLine("The Motorcycle Cargo Capacity is :{0} ", cargoCapacity);
class Automobile : Vehicle
public override void CargoCapacity()
int cargoCapacity = (length * width * height);
Console.WriteLine("The Automobile cargoCapacity is :{0} ", cargoCapacity);