
October 23rd, 2007, 07:35 AM
|
|
Registered User
|
|
Join Date: Oct 2007
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
StringBuilder.AppendFormat(format as String, ParamArray args() as Object) usage...
Howdy,
My first post  .
I want to use the overloaded version of the AppendFormat method in the title to this thread but I really don't see the point.
The AppendFormat format argument requires you to use the syntax {N} where N is the index of the parameter you want to format.
I want to do something like this...
Code:
Protected Function SetPacketData(ByVal ParamArray Parameters() As Object) As String
Dim PacketData As New System.Text.StringBuilder
PacketData.AppendFormat("{0}", Parameters)
Return PacketData.ToString()
End Function
Obviously "{0}" will only format the first index in the parameters array, so what is the point of having this overloaded method if the format argument *needs to know* the index it needs to format, and a ParamArray can have X amount of elements? I want to format the whole Parameters() object at once? To get around this I have to use a For loop and loop through each element of Parameters().
Has anyone else encountered this problem before and has a viable solution (if any)?
Thanks.
Edit:
I ended up doing it the long way.
|