-1

Please can anyone advise me on how i can replace a particular character from a 2 mb string without using replace function in .NET

Thanks

Amit
  • 6,839
  • 21
  • 56
  • 90
  • 3
    You can use a `StringBuilder` or `unsafe` code. Be more specific about what you're trying to do. – Gabe Dec 10 '10 at 08:47
  • 3
    why don't you want to use replace function? – pavanred Dec 10 '10 at 08:47
  • well, i knw replace is the best way to do it but i am after exploring more options/ways to do it – Amit Dec 10 '10 at 08:48
  • Because replace function creates a new string; string is immutable. @Gabe is right, use StringBuilder. – Dmitry Karpezo Dec 10 '10 at 08:49
  • 1
    please refer this link , it has a good comparison between the 'replace' functions http://blogs.msdn.com/b/debuggingtoolbox/archive/2008/04/02/comparing-regex-replace-string-replace-and-stringbuilder-replace-which-has-better-performance.aspx – wizzardz Dec 10 '10 at 08:53

1 Answers1

1

You should have a look at some of the solutions discussed here:

Memory Efficiency and Performance of String.Replace .NET Framework

It mentions the use of Regex.Replace and StringBuilder.Replace

Community
  • 1
  • 1
Malachi
  • 33,142
  • 18
  • 63
  • 96