protected void DisplayReceipt() { //the stringbuilder is an object that //allows you to build complex strings //It is easier than concatinating StringBuilder sb = new StringBuilder(); //get the MealOrder class from the session //it has to be cast from type "object" MealOrder meal = (MealOrder)Session["Meal"]; //copy the lists from the object List <string> entrees = meal.Entrees; List <string> drinks = meal.Drinks; //loop through to get the values foreach (string entree in entrees) { sb.Append(entree); sb.Append("<br/>"); } foreach (string drink in drinks) { sb.Append(drink); sb.Append("<br/>"); } //get the total sb.Append(meal.CalculateTotal().ToString()); //display the string Label1.Text = sb.ToString(); }
protected void DisplayReceipt() { StringBuilder sb = new StringBuilder(); MealOrder meal = (MealOrder)Session["Meal"]; List <string> entrees = meal.Entrees; List <string> drinks = meal.Drinks; foreach (string entree in entrees) { sb.Append(entree); sb.Append("<br/>"); } foreach (string drink in drinks) { sb.Append(drink); sb.Append("<br/>"); } sb.Append(meal.CalculateTotal().ToString()); Label1.Text = sb.ToString(); }