Replace first occurrence of pattern in a string [duplicate]

Possible Duplicate:
How do I replace the first instance of a string in .NET?

Let’s say I have the string:

string s = "Hello world.";

how can I replace the first o in the word Hello for let’s say Foo?

In other words I want to end up with:

"HellFoo world."

I know how to replace all the o’s but I want to replace just the first one

3 Answers
3

Leave a Comment