"stringbuilder c# jump over char" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "stringbuilder c# jump over char" answered properly. Developers are finding an appropriate answer about stringbuilder c# jump over char related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like stringbuilder c# jump over char. Enter your desired code related query in the search bar and get every piece of information about C# code related question on stringbuilder c# jump over char. 

stringbuilder c# jump over char

By Jittery JellyfishJittery Jellyfish on Oct 12, 2020
using System;
using System.Text;

class Sample
{
    public static void Main()
    {
//                0----+----1----+----2----+----3----+----4---
//                01234567890123456789012345678901234567890123
    string str = "The quick br!wn d#g jumps #ver the lazy cat.";
    StringBuilder sb = new StringBuilder(str);

    Console.WriteLine();
    Console.WriteLine("StringBuilder.Replace method");
    Console.WriteLine();

    Console.WriteLine("Original value:");
    Show(sb);

    sb.Replace('#', '!', 15, 29);        // Some '#' -> '!'
    Show(sb);
    sb.Replace('!', 'o');                // All '!' -> 'o'
    Show(sb);
    sb.Replace("cat", "dog");            // All "cat" -> "dog"
    Show(sb);
    sb.Replace("dog", "fox", 15, 20);    // Some "dog" -> "fox"

    Console.WriteLine("Final value:");
    Show(sb);
    }

    public static void Show(StringBuilder sbs)
    {
    string rule1 = "0----+----1----+----2----+----3----+----4---";
    string rule2 = "01234567890123456789012345678901234567890123";

    Console.WriteLine(rule1);
    Console.WriteLine(rule2);
    Console.WriteLine("{0}", sbs.ToString());
    Console.WriteLine();
    }
}
/*
This example produces the following results:

StringBuilder.Replace method

Original value:
0----+----1----+----2----+----3----+----4---
01234567890123456789012345678901234567890123
The quick br!wn d#g jumps #ver the lazy cat.

0----+----1----+----2----+----3----+----4---
01234567890123456789012345678901234567890123
The quick br!wn d!g jumps !ver the lazy cat.

0----+----1----+----2----+----3----+----4---
01234567890123456789012345678901234567890123
The quick brown dog jumps over the lazy cat.

0----+----1----+----2----+----3----+----4---
01234567890123456789012345678901234567890123
The quick brown dog jumps over the lazy dog.

Final value:
0----+----1----+----2----+----3----+----4---
01234567890123456789012345678901234567890123
The quick brown fox jumps over the lazy dog.

*/

Source: docs.microsoft.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on stringbuilder c# jump over char can get a collection of related answers to their query. Programmers need to enter their query on stringbuilder c# jump over char related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about stringbuilder c# jump over char for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of stringbuilder c# jump over char while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "stringbuilder c# jump over char". Visit this developer's friendly online web community, CodeProZone, and get your queries like stringbuilder c# jump over char resolved professionally and stay updated to the latest C# updates. 

C# answers related to "stringbuilder c# jump over char"

View All C# queries

C# queries related to "stringbuilder c# jump over char"

Browse Other Code Languages

CodeProZone