c# example - convert stringbuilder to string
convert-stringbuilder-to-string.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
StringBuilder stringb = new StringBuilder();
stringb.Append(" Crimson");
//insert a boolean value at index 0.
stringb.Insert(0, false);
stringb.Insert(0, " || "); //insert a separator here
//insert a char value at index 0.
stringb.Insert(0, 'D');
stringb.Insert(0, " || "); //insert a separator here
//insert a double value at index 0.
stringb.Insert(0, 21.36);
stringb.Insert(0, " || "); //insert a separator here
//insert a float value at index 0.
stringb.Insert(0, 4.88f);
stringb.Insert(0, " || "); //insert a separator here
//insert a int value at index 0.
stringb.Insert(0, 85);
stringb.Insert(0, " || "); //insert a separator here
//insert a string value at index 0.
stringb.Insert(0, "yellow");
//insert a string value at index 6.
stringb.Insert(6, ":::::");
//this is the final string which we get from stringbuilder.
string finalstring = stringb.ToString();
Label1.Text = finalstring;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - convert stringbuilder to string</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - convert stringbuilder to string
</h2>
<hr width="550" align="left" color="Gainsboro" />
<br />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="convert stringbuilder to string"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to create bold text inside a StringBuilder
- How to get the capacity of a StringBuilder
- How to insert a string into a StringBuilder
- How to replace a string in a StringBuilder
- How to replace a string in a StringBuilder case insensitive
- How to write a StringBuilder data to a CSV file
- How to check if a StringBuilder is empty
- How to reverse a StringBuilder
- How to trim a StringBuilder
- How to convert a StringBuilder characters to uppercase