"Phil Sandler" <ps********@hotmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Hello,
What is the fastest/most efficient way of doing string replacement in
csharp/.net?
An example would be:
"Hello, my name is {FirstName}, and I live in the town of {City} with
my wife {WifeName} and my {NumKids} children."
I have this working with regular expressions, but I'm wondering if
that's the best/fastest method. Would writing this in another
language (say, C++) improve the performance?
Depends on whether a particular template is reused with different data... if
so, it makes a lot of sense to parse it only once, then the parsing speed
becomes less important than the final encoding. Something like:
array of literals: { "Hello, my name is ", ", and I live in the town of ",
.... }
array of field indexes, negative if reference to literal, positive if
reference to database field
will take moderate additional processing to set up, but be very fast to
execute across a dataset.
>
Thanks for any insight.
Phil