CSharp examples for Language Basics:StringBuilder
Demonstrating StringBuilder Append methods.
using System;/*from w w w . j av a2 s . c om*/ using System.Text; class StringBuilderAppend { static void Main() { object objectValue = "hello"; var stringValue = "good bye"; char[] characterArray = { 'a', 'b', 'c', 'd', 'e', 'f' }; var booleanValue = true; var characterValue = 'Z'; var integerValue = 7; var longValue = 1000000L; // L suffix indicates a long literal var floatValue = 2.5F; // F suffix indicates a float literal var doubleValue = 33.333; var buffer = new StringBuilder(); // use method Append to append values to buffer buffer.Append(objectValue); buffer.Append(" "); buffer.Append(stringValue); buffer.Append(" "); buffer.Append(characterArray); buffer.Append(" "); buffer.Append(characterArray, 0, 3); buffer.Append(" "); buffer.Append(booleanValue); buffer.Append(" "); buffer.Append(characterValue); buffer.Append(" "); buffer.Append(integerValue); buffer.Append(" "); buffer.Append(longValue); buffer.Append(" "); buffer.Append(floatValue); buffer.Append(" "); buffer.Append(doubleValue); Console.WriteLine($"buffer = {buffer.ToString()}"); } }