c# - concatenation issue adding static string to dynamic string -




the following code working fine static value "application1".

mailmsg.headers.add("x-smtpapi", "{ \"category\": [ \"application1\" ] }"); 

but want replace "application1" dynamic value.

so implemented following code. dtls.category dynamic value.

string xsmtpcategory = "{\"category\":\""+dtls.category +"\" ] }"; mailmsg.headers.add("x-smtpapi", xsmtpcategory); 

but i'm getting error "not in correct format".

how can fix that?

you left out part of syntax after colon:

string xsmtpcategory = "{\"category\": [ \""+dtls.category +"\" ] }"; 

i suggest using c# 6.0 string interpolation if possible:

mailmsg.headers.add("x-smtpapi", $@"{{ ""category"": [ ""{dtls.category}"" ] }}"); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -