System.Text.StringBuilder.Replace C# (CSharp) Method

Replace() public method

public Replace ( char oldChar, char newChar, int startIndex, int count ) : StringBuilder
oldChar char
newChar char
startIndex int
count int
return StringBuilder
		public StringBuilder Replace (char oldChar, char newChar, int startIndex, int count) 
		{
			// re-ordered to avoid possible integer overflow
			if (startIndex > _length - count || startIndex < 0 || count < 0)
				throw new ArgumentOutOfRangeException();

			if (null != _cached_str)
				InternalEnsureCapacity (_str.Length);

			for (int replaceIterate = startIndex; replaceIterate < startIndex + count; replaceIterate++ ) {
				if( _str [replaceIterate] == oldChar )
					_str.InternalSetChar (replaceIterate, newChar);
			}

			return this;
		}

Same methods

StringBuilder::Replace ( char oldChar, char newChar ) : StringBuilder
StringBuilder::Replace ( string oldValue, string newValue ) : StringBuilder
StringBuilder::Replace ( string oldValue, string newValue, int startIndex, int count ) : StringBuilder

Usage Example

Beispiel #1
0
        public string Compile(bool minify)
        {
            var js = jslastvalid;
            var html = htmllastvalid;

            // Merge fields
            var output = new StringBuilder(html);
            output.Replace("%resourcepath%", Program.BlobPathResource);
            output.Replace("%build%", Program.Config.Configuration.Build.ToString());
            output.Replace("%buildserial%", Program.Config.Configuration.BuildSerial.ToString());
            html = output.ToString();

            // Minify
            if (minify) {
                js = Minify.MinifyJS(js);
                html = Minify.MinifyHTML(html);
            }

            // Add JS
            var doc = new HtmlDocument();
            doc.LoadHtml(html);
            doc.GetElementbyId("_script_").AppendChild(doc.CreateComment(js));

            return doc.DocumentNode.OuterHtml;
        }
All Usage Examples Of System.Text.StringBuilder::Replace