C# StringReader Read(Char[], Int32, Int32)

Description

StringReader Read(Char[], Int32, Int32) Reads a block of characters from the input string and advances the character position by count.

Syntax

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


public override int Read(
  char[] buffer,/*from   w  ww .j  a va  2  s  .c  o m*/
  int index,
  int count
)

Parameters

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

  • buffer - When this method returns, contains the specified character array with the values between index and (index + count - 1) replaced by the characters read from the current source.
  • index - The starting index in the buffer.
  • count - The number of characters to read.

Returns

StringReader.Read(Char[], Int32, Int32) method returns The total number of characters read into the buffer. This can be less than the number of characters requested if that many characters are not currently available, or zero if the end of the underlying string has been reached.

Example


using System;/*from w  w  w.  jav a 2 s . c om*/
using System.IO;
public class MainClass{
  public static void Main(String[] argv){  
    StringReader strReader = new StringReader("java2s.com java2s.com");
    char[] chars = new char[10];
    strReader.Read(chars,0,10);
  }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter