String Formatting

02/02/2005 - 11:16 por Ohad | Informe spam
Hello,

I have a const string, who looks something like this:

const str = "abc {name: ohad phone: xxxxxx} {0} {1} {2}";

and i'd like to do this:

string a = string.Format(str, 1, 2, 3);

It's not working. I guess that the problem is that the c#'s Format method
looks at the string between the first {} like it is a parameter, like {0}
{1} {2}.
How can I solve it? I was working so hard to solve this problem, and
nothing.

please cc to my mailbox: ohad@usbphone.com

Thanks a lot,
Ohad Asor.
 

Leer las respuestas

#1 Anders Norås
02/02/2005 - 11:34 | Informe spam
Ohad wrote:
Mostrar la cita
You must escape the brackets by using two brackets instead of one when
they're not part of an format expression. Like this:
const str = "abc {{name: ohad phone: xxxxxx}} {0} {1} {2}";

Anders Norås
http://dotnetjunkies.com/weblog/anoras/

Preguntas similares