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.

Preguntas similare

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/
#2 Frank Dzaebel
02/02/2005 - 11:35 | Informe spam
Konnichi wa Ohad,

Nan to iimas ka ?
Kore wa Doitsu no Newsgroup desu ne !
Dewa mata ...

ciao Frank
Dipl.Inf. Frank Dzaebel [MCP C#]
#3 Anonimo
02/02/2005 - 15:40 | Informe spam
Un poquito de por favor !!!!

La lengua de Cervantes domina este foro.

Gracias, apañeros.


Mostrar la cita
#4
05/02/2005 - 01:59 | Informe spam
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}";
上面同志说的很对
Ads by Google
Search Busqueda sugerida