Appends various data to StringBuilder : StringBuilder « Development Class « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Development Class » StringBuilderScreenshots 
Appends various data to StringBuilder
 


using System;
using System.Text;

class Sample 
{
    public static void Main() 
    {
        Object   obj       = 0;
    
        bool        xBool     = true;
        byte        xByte     = 1;
        short       xInt16    = 2;
        int         xInt32    = 3;
        long        xInt64    = 4;
        Decimal     xDecimal  = 5;
        float       xSingle   = 6.6F;
        double      xDouble   = 7.7;
    
        ushort      xUInt16   = 8;
        uint        xUInt32   = 9;
        ulong       xUInt64   = 10;
        sbyte       xSByte    = -11;
    
        StringBuilder sb = new StringBuilder();
    
        sb = sb.Append(xBool);
        sb = sb.Append(obj).Append(xByte);
        sb = sb.Append(xInt16);
        sb = sb.Append(xInt32);
        sb = sb.Append(xInt64);
        sb = sb.Append(xDecimal);
        sb = sb.Append(xSingle).Append(xDouble);
    
        sb = sb.Append(xUInt16);
        sb = sb.Append(xUInt32).Append(xUInt64);
        sb = sb.Append(xSByte);
    
        String str = sb.ToString();
        Console.WriteLine("The appended string is:");
        Console.WriteLine(str);
    }
}

   
  
Related examples in the same category
1.Create a StringBuilder which hold 100 characters.
2.Length and Indexer
3.Use StringBuilder to reverse a string
4.using the StringBuilder methods Replace, Insert, Append, AppendFormat, and Remove:
5.String ConcatenationString Concatenation
6.illustrates reading and writing string dataillustrates reading and writing string data
7.Replace char in a StringBuilder object
8.Replace Char with String
9.Represents a mutable string of characters.
10.Create StringBuilder class using the specified capacity.
11.Create StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
12.Create a StringBuilder class using the specified string.
13.Create StringBuilder class using the specified string and capacity.
14.Create StringBuilder class from the specified substring and capacity.
15.Appends a composite format string
16.Appends the default line terminator to the end of the current StringBuilder object.
17.Gets or sets the maximum number of characters that can be contained
18.Removes all characters from the current StringBuilder instance.
19.Copies characters to a destination Char array.
20.Inserts various data types
21.Removes the specified range of characters from this instance.
22.Replaces all occurrences of a specified character in this instance with another specified character.
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.