How to use the replace method in StringBuilder in C#

2 Answers

0 votes
using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder("This is an example of string builder replace method");

            sb.Replace("method", "function");

            Console.WriteLine(sb); // This is an example of string builder replace function
        }
    }
}

/*
run:
  
This is an example of string builder replace function

*/


answered Feb 24, 2015 by avibootz
0 votes
using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder("This is an example of string builder replace method");

            sb.Replace("is", "***");

            Console.WriteLine(sb); // Th*** *** an example of string builder replace method
        }
    }
}

/*
run:
  
Th*** *** an example of string builder replace method

*/


answered Feb 24, 2015 by avibootz

Related questions

1 answer 159 views
1 answer 117 views
1 answer 91 views
2 answers 115 views
1 answer 140 views
1 answer 124 views
1 answer 99 views
...