【发布时间】:2016-07-08 00:59:42
【问题描述】:
我正在尝试在 C# 中编辑我的 Fuel Consumed 行以在数字数量之后输出单词“gallons”。我不确定如何操作 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"); }
【问题讨论】:
-
您现在面临的问题是什么?