[Serializable] |
ctor #1 | Initializes a new instance of the StringReader class that reads from the specified string. |
Close | Overridden: Closes the StringReader. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
Peek | Overridden: Returns the next available character but does not consume it. |
Read | Overloaded:Read() Overridden: Reads the next character from the input string and advances the character position by one character. |
Read | Overloaded:Read(in char[] buffer, int index, int count) Overridden: Reads a block of characters from the input string and advances the character position by count. |
ReadBlock (inherited from System.IO.TextReader) |
See base class member description: System.IO.TextReader.ReadBlock Reads a maximum of count characters from the current stream and writes the data to buffer, beginning at index. |
ReadLine | Overridden: Reads a line from the underlying string. |
ReadToEnd | Overridden: Reads the stream as a string, either in its entirety or from the current position to the end of the stream. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Dispose | Overridden: Releases the unmanaged resources used by the StringReader and optionally releases the managed resources. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public StringReader( |
s
Exception Type | Condition |
---|---|
ArgumentNullException | The s parameter is null. |
public override void Close(); |
This implementation of Close calls the StringReader.Dispose method passing a true value.
Flushing the stream will not flush its underlying encoder unless you explicitly call Close. Setting StreamWriter.AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.
Following a call to Close, other methods might throw an exception.
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
protected override void Dispose( |
disposing
~StringReader(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
public override int Peek(); |
Exception Type | Condition |
---|---|
ObjectDisposedException | The current reader is closed. |
The current position of the StringReader is not changed by this operation.
public override int Read(); |
Exception Type | Condition |
---|---|
ObjectDisposedException | The current reader is closed. |
buffer
index
count
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | The buffer length minus index is less than count. |
ArgumentOutOfRangeException | index or count is negative. |
ObjectDisposedException | The current reader is closed. |
The method will read up to count characters from the StringReader into the buffer character array starting at position index. Returns the actual number of characters read, or zero if the end of the string has been reached and no characters are read.
buffer
index
count
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | The buffer length minus index is less than count. |
ArgumentOutOfRangeException | index or count is negative. |
IOException | An I/O error occurs. |
public override string ReadLine(); |
Exception Type | Condition |
---|---|
ObjectDisposedException | The current reader is closed. |
OutOfMemoryException | There is insufficient memory to allocate a buffer for the returned string. |
A line is defined as a sequence of characters followed by a carriage return ("\r"), a line feed ("\n"), or a carriage return immediately followed by a line feed. The resulting string does not contain the terminating carriage return and/or line feed. The returned value is null if the end of the underlying string has been reached.
If the current method throws an OutOfMemoryException, the reader's position in the underlying string is advanced by the number of characters the method was able to read, and the characters already read into the internal StringReader.ReadLine buffer are discarded. Since the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the StringReader. To avoid such a situation and produce robust code you should use the StringReader.Read method and store the read characters in a preallocated buffer.
public override string ReadToEnd(); |
Exception Type | Condition |
---|---|
OutOfMemoryException | There is insufficient memory to allocate a buffer for the returned string. |
ObjectDisposedException | The current reader is closed. |
If the current method throws an OutOfMemoryException, the reader's position in the underlying string is advanced by the number of characters the method was able to read, and the characters already read into the internal StringReader.ReadToEnd buffer are discarded. Since the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the StringReader. To avoid such a situation and produce robust code you should use the StringReader.Read method and store the read characters in a preallocated buffer.
public virtual string ToString(); |