Answers for "stringbuilder"

8

c# stringbuilder

using System;
using System.Text;

public sealed class App 
{
    static void Main() 
    {
        // Create a StringBuilder that expects to hold 50 characters.
        // Initialize the StringBuilder with "ABC".
        StringBuilder sb = new StringBuilder("ABC", 50);

        // Append three characters (D, E, and F) to the end of the StringBuilder.
        sb.Append(new char[] { 'D', 'E', 'F' });

        // Append a format string to the end of the StringBuilder.
        sb.AppendFormat("GHI{0}{1}", 'J', 'k');

        // Display the number of characters in the StringBuilder and its string.
        Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());

        // Insert a string at the beginning of the StringBuilder.
        sb.Insert(0, "Alphabet: ");

        // Replace all lowercase k's with uppercase K's.
        sb.Replace('k', 'K');

        // Display the number of characters in the StringBuilder and its string.
        Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());
    }
}

// This code produces the following output.
//
// 11 chars: ABCDEFGHIJk
// 21 chars: Alphabet: ABCDEFGHIJK
Posted by: Guest on March-12-2020
10

java string builder

StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append("string");

System.out.println("String = " + stringBuilder.toString());
Posted by: Guest on September-06-2020
1

stringbuilder java

StringBuilder objects are like String objects, except that they can be modified
Posted by: Guest on August-21-2021
1

why string builder

StringBuilder is for, well, building strings.
Specifically, building them in a very
performance way. The String class is good
for a lot of things, but it actually has
really terrible performance when assembling 
a new string out of smaller string parts
because each new string is a totally new,
reallocated string.
Posted by: Guest on January-19-2021
1

stringbuilder

It is mutable char sequence and it is not
thread safe.
Posted by: Guest on January-05-2021

Browse Popular Code Answers by Language