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 189 views
1 answer 152 views
1 answer 135 views
2 answers 166 views
1 answer 171 views
1 answer 153 views
1 answer 129 views
...