我试图在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"); }
什么是你现在所面临的问题是什么? –