I have this string :
Hello my name is Marco
and I’d like to replace the first space (between Hello and my) with <br />. Only the first.
What’s the best way to do it on C#/.NET 3.5?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No need to add substrings, following will find the first space instance only.
From MSDN:
Edit: If you are not sure if space will occur, some validations must come into place. I have edit the answer accordingly.