Wednesday, December 12, 2012

Replace text in C#.NET

We can use Replace() method to replace specified text in a string. See the below example.

private void ReplaceText()
  string Statement = "My Country is India";
  Statement= Statement.Replace("India","Sri lanka");

Above code will replace the text "India" in original string to "Sri lanka".

Out put:
My Country is Sri lanka

No comments:
Write comments
Recommended Posts × +