I've said as much in the comments, but I think it's worth an answer by now:
Don't use string.Format
(in this case). It's slower, and less readable. Just use plain string concatenation with meaningful variable names if you need complex concatenations - these will be faster and more maintainable. Faster because for a fixed number of segments plain +
is the fastest option due to compiler optimizations, and more maintainable because the reader can see the context within the string in which the variable is put.
As Hans Passant noted, it looks like you're making a javascript literal. If that's the case, consider a Json serializer like Json.NET instead:
JsonConvert.SerializeObject(new {
cmd = "save magellan deal",
data = new {
id = 12345, AId = 1, CId = 2, CCId = 21,
LA = "reidb", BA = "reidb", LSA = "reidb", BSA = "reidb",
path = "aa", dscp = "Some description", SI = 11,
CD = "2012-02-28", period = "2012-01-29",
IsStatic = true, LSD = 1, LC = 1, RB = true,
},
Notes = "note note note",
IsEE = true, RBy = 1, DPDD = "2011-12-03", LId = 45
})
While Json.NET
does support DateTime
serialization, there's not standardized format for dates in JS, so these are serialized as strings in an iso 8601 format. This might not be what you need, hence the date strings in this example - I'd try the iso format first, though, as that's the simplest solution.