using System; using Microsoft.SPOT; namespace UTILS { public static class StringExtensions { // Replace all occurances of the 'find' string with the 'replace' string. public static string Replace(this string content, string find, string replace) { int startFrom = 0; int findItemLength = find.Length; int firstFound = content.IndexOf(find, startFrom); StringBuilder returning = new StringBuilder(); string workingString = content; while ((firstFound = workingString.IndexOf(find, startFrom)) >= 0) { returning.Append(workingString.Substring(0, firstFound)); returning.Append(replace); // the remaining part of the string. workingString = workingString.Substring(firstFound + findItemLength, workingString.Length - (firstFound + findItemLength)); } returning.Append(workingString); return returning.ToString(); } } }