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 276 views
1 answer 245 views
1 answer 232 views
2 answers 302 views
1 answer 265 views
1 answer 252 views
1 answer 226 views
...