Replace string in C#

Home arrow .NET Tutorials arrow C# arrow Replace string in C#
Replace string in C# Print E-mail
Contributed by Howell   
Monday, 12 June 2006
//Replace string function.
public static String Replace(String oText,String oFind,String
oReplace)
{
   int iPos=oText.IndexOf(oFind);
   String strReturn="";
   while(iPos!=-1)
   {
     strReturn+=oText.Substring(0,iPos) + oReplace;
     oText=oText.Substring(iPos+oFind.Length);
     iPos=oText.IndexOf(oFind);
   }
   if(oText.Length>0)
     strReturn+=oText;
   return strReturn;
}
}

  home              contact us

 

©2006-2008 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground