C # Coding. IO System

Source: Internet
Author: User

I/O system

1. Basic Concepts

Data Stream: an abstraction that generates or uses information, including byte data streams and character data streams;

Byte data streams and character data streams: byte data streams can process ASCII character sets, but are not suitable for handling Unicode characters. character data streams can process the latter;

2. byte data streams)

System. IO. Stream: the Stream class represents the byte data Stream. It is an abstract class and is the base class of all other data Stream classes, including some common methods and attributes;

Http://msdn.microsoft.com/en-us/library/system.io.stream.aspx

Some specific byte data Stream classes are derived from the Stream class, such as BufferedStream, FileStream, MemoryStream, and UnmanagedMenoryStream)

3. character data stream

The TextReader and TextWrite classes represent character data streams. They are abstract classes and are the base classes of all other character data streams, including some common methods and attributes;

Http://msdn.microsoft.com/en-us/library/system.io.textreader.aspx

Http://msdn.microsoft.com/en-us/library/system.io.textwriter.aspx

Some data stream classes that implement the TextReader and TextWrite classes include StreamReader, StreamWriter, StringReader, and StringWriter)

4. Console I/O

The relationship between the console I/O and the character data stream class has not been clarified during the first reading, so I will repeat it again.

First, we will introduce the character data stream of the standard data stream), that is, Console. In, Console. Out, and Console. Error. You only need to know the standard data stream)

Secondly, we need to clarify the relationship between the Console. In data stream, Console class, And TextReader class.

Public staticTextReaderIn {get ;}

Console. in is a property of the Console class. This property can return the objects of the TextReader class. in data stream is an instance of the TextReader class ", Console. in. read () is actually calling the Read () method of TextReader, TextReader. read ).

PublicstaticintRead()
{
ReturnIn. Read ();
}

Then you need to understand the Console. the Read () method is Console. the code of the Read () method returns In. read (), then Console. read () is to call the Console first. the In attribute instantiates TextReader and then calls its Read () method, which is equivalent to the Console. in. read ().

The principles of other methods such as ReadLine () are the same.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.