Click here to Skip to main content
15,905,682 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to create a string builder example

please help me
Posted
Comments
Sergey Alexandrovich Kryukov 31-Jul-12 12:37pm    
Broken MSDN?
--SA

Whats the Problem with the MSDN Example?
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx[^]

Following Code is Copy Pasted from MSDN:
C#
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
 
Share this answer
 
Comments
pradiprenushe 31-Jul-12 7:26am    
My 5
C#
System.Text.Stringbuilder sb = new  System.Text.Stringbuilder;
sb.AppendLine("TEST1");
sb.AppendLine("TEST2");
sb.AppendLine("TEST3");
sb.AppendLine("TEST4");
String str = new String;
str = sb.ToString;
 
Share this answer
 
v2
Hi,
refer this[^] it will help u lot
Best Luck
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900