C# String String(Char[], Int32, Int32) Array

Description

String String(Char[], Int32, Int32) initializes a new instance of the String class to the value indicated by an array of Unicode characters, a starting character position within that array, and a length.

Syntax

String.String(Char[], Int32, Int32) has the following syntax.


public String(//from w  w  w . j  a v  a  2s.  co  m
  char[] value,
  int startIndex,
  int length
)

Parameters

String.String(Char[], Int32, Int32) has the following parameters.

  • value - An array of Unicode characters.
  • startIndex - The starting position within value.
  • length - The number of characters within value to use.

Example


/*from  w w  w .  j a  v  a2 s  .c o m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    System.Console.WriteLine(new String(new char[]{'a','b','c','d','e'},1,2));
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version