0

Using the C#'s String.Replace function replaces all instances of A with B found in the string s if I write this: string c = s.Replace(A, B);

I would like to replace only several instances of A with B.

So, for example, for s=jjjk-A--iii-A---A---A (Which has 4 instances of A), I would like to replace only the first two instances with B so that eventually I get jjjk-B--iii-B---A---A.

I can do it manually. Is there any C# function which does that?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Idanis
  • 1,918
  • 6
  • 38
  • 69

0 Answers0