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
  • 148,824
  • 21
  • 237
  • 306
Idanis
  • 1,858
  • 6
  • 35
  • 67

0 Answers0