这段代码不会打印价值年份,我无法弄清楚原因。
String words = string.Format("{0,-60}" + "|" + "{0,-7}" + "|" + "{0,-20}" +
"|" + "{0,-20}", Title, Year, Album, Artist);
其他所有工作,如果我打印每个值没有像这样的格式,它工作正常
String words = string.Format(Title + ", " + Year + ", " + album + ", " +
Author); //works
你拥有它的方式只是在格式字符串中引用了Title参数。试试String words = string.Format("{0,-60}" + "|" + "{1,-7}" + "|" + "{2,-20}" +
"|" + "{3,-20}", Title, Year, Album, Artist);
有关String.Format行为的更多信息,请访问:https://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx