StringBuilder sample Example -1

Posted by Venkat | Labels: ,

Here we have to see the sample of stringbuilder ,

System.StringBuilder is mutable where variety of operations can be performed

System.String is immutable variable value may change BUT original data value will be discarded and new value will be in memory.

Add one listbox on your webform and add three items on design mode.

protected void Page_Load(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array =" new" x =" this.ListBox1.Items[i].ToString();"> 0)
{
if ((builder.Length) != (ListBox1.Items.Count))
{

builder.Append(",");
// x += ",";
}
}

// Response.Write(builder);

}
string s = builder.ToString();
s = s.Substring(0, s.Length - 1);
Response.Write(s);
}

0 comments:

Post a Comment

Thanks for the Comments.

PayOffers.in