此代码不会打印价值年份,我无法弄清楚原因。
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
答案 0 :(得分:2)
您拥有它的方式只是在格式字符串中引用了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