Reputation: 4112
So i have a VB.net String here that looks as such below.
I have another string startId
that i wish is substituted in the appropriate places.
So i wrote the following lines.
Dim jsonPayloadHeaderFormat As String = "Content-Type: application/json;charset=UTF-8" & "\r\n" & "Content-ID: {0}" & "\r\n" & "Content-Disposition: attachment; filename={0}" & "\r\n" & "{" & "\r\n"
String.Format(jsonPayloadHeaderFormat, startId)
But i get a input string not in correct format
error.
I am new to vb.net and can't seem to get it.
Please advise.
Upvotes: 2
Views: 220
Reputation: 460238
Because of the {\r\n
at the end. {
indidcates that you want to begin a new element. Opening and closing braces are required. Read the remarks section.
You also have to assign the new string which is returned from String.Format
to a string variable:
Dim jsonPayloadHeaderFormat As String = "Content-Type: application/json;charset=UTF-8" & "\r\n" & "Content-ID: {0}" & "\r\n" & "Content-Disposition: attachment; filename={0}" & "\r\n\r\n"
Dim result As String = String.Format(jsonPayloadHeaderFormat, startId)
Upvotes: 2