我試圖在C#中編輯我的Fuel Consumed行,輸出數字數量後的單詞「gallons」。我不知道如何操作ToString來完成此操作。任何幫助,將不勝感激。使用ToString格式化輸出
// toString method to display object information
public override string ToString()
{ return "\n\nDestination: " + destinationCity +
"\n\nTotal Miles: " + mileageRoundTrip.ToString("F0") +
"\n\nFuel Consumed: " + gallonsUsed.ToString("F1") +
"\n\nFuel Cost Per Gallon: " + gallonsCost.ToString("C") +
"\n\nTotal Fuel Cost for this Trip: " + totalFuelCost.ToString("C") +
"\n\nMPG: " + amountMPG.ToString("F0") +
"\n\nFuel Cost Per Mile: " + costPerMile.ToString("C"); }
什麼是你現在所面臨的問題是什麼? –