C# StringBuilder StringBuilder(String, Int32, Int32, Int32)

Description

StringBuilder StringBuilder(String, Int32, Int32, Int32) Initializes a new instance of the StringBuilder class from the specified substring and capacity.

Syntax

StringBuilder.StringBuilder(String, Int32, Int32, Int32) has the following syntax.


public StringBuilder(
  string value,/*from   w w  w .j a  v  a2s . co m*/
  int startIndex,
  int length,
  int capacity
)

Parameters

StringBuilder.StringBuilder(String, Int32, Int32, Int32) has the following parameters.

  • value - The string that contains the substring used to initialize the value of this instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).
  • startIndex - The position within value where the substring begins.
  • length - The number of characters in the substring.
  • capacity - The suggested starting size of the StringBuilder.

Example

The following example demonstrates how to call the StringBuilder constructor with the specified string.


using System;/*  w ww .  j a v  a 2s .co m*/
using System.Text;

class Sample 
{
    public static void Main() 
    {
        string initialString = "Initial string for stringbuilder.";
        int startIndex = 0;
        int substringLength = 14;
        int capacity = 255;
        StringBuilder stringBuilder = new StringBuilder(initialString, startIndex, substringLength, capacity);
    }
}




















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding