我正在尝试使用数组列表作为 String.Format 的参数。
msg = msg & String.Format("<td>{0}</td>" & _
"<td>{1}</td>" & _
"<td>{2}</td>" & _
"<td>{3}</td>" & _
"<td>{4}</td>" & _
"<td>{5}</td>" & _
"<td>{6}</td>" & _
"<td>{7}</td>" & _
"<td>{8}</td>", param)
其中 param 是一个 ArrayList,内容如下(从监视列表复制):
+ (0) 9 {Integer} Object
+ (1) 3 {Integer} Object
+ (2) 5 {Integer} Object
+ (3) "180" {String} Object
+ (4) 0D {Decimal} Object
+ (5) 6.788D {Decimal} Object
+ (6) #3/13/2009# {Date} Object
+ (7) "2004" {String} Object
+ (8) "" {String} Object
但是这段代码抛出了 FormatException
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
我是否错误地认为可以使用数组列表?如果可能的话,有什么线索可以解释为什么会抛出这样的错误吗?
谢谢
最佳答案
它接受ArrayList
吗?
你尝试过吗:
"<td>{8}</td>", param.ToArray())
关于Vb.NET String.Format 与 ArrayList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2950835/