我試圖格式化字符串的大小,使用值的數組:的String.Format:(基於零)索引必須大於或等於零且小於參數列表
Dim args(2) As Object
args(0) = "some text"
args(1) = "more text"
args(2) = "and other text"
Test(args)
,功能測試是:
Function Test(ByVal args As Object)
Dim MailContent as string = "Dear {0}, This is {1} and {2}."
'tried both with and without converting arr to Array
args = CType(args, Array)
MailContent = String.Format(MailContent, args) 'this line throws the error: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
End Function
這是特別的語言嗎? –