-4

I have a string like this "ALTA Homeowner's Policy of Title Insurance". I want to remove colon from above string(which one beside home owner)? how to do this by using C#

ramesh
  • 13
  • 1

1 Answers1

0

One way is finding the index of colon and then using remove method available for String object.

int index;
string s = "ALTA Homeowner's Policy of Title Insurance";
string output;
index = s.IndexOf('\'');
if (index != -1)
{
      output = s.Remove(index, 1);
      Console.Out.WriteLine(output);
}

Escape character '\' is used to catch colon.

IndexOf method return the index of first occurance of a matching character. Other methods like IndexOfAny,LastIndexOf are also available.

Rohit
  • 895
  • 1
  • 9
  • 19