当前位置:网站首页>C IO stream (II) extension class_ Packer
C IO stream (II) extension class_ Packer
2022-06-26 00:43:00 【Tianma 3798】
One 、C# IO Stream Stream extension class
C# The following standards are included IO( Input / Output ) class , From different sources ( Such as files , Memory , The Internet , Isolated storage, etc ) To read / write in .
flow (Stream): System.IO.Stream Is an abstract class , Provides the byte ( read , Writing, etc ) Standard method of transfer to source . Transfer bytes just like wrapper classes . Need to read from a specific source / Classes that write bytes must implement Stream class .
The following classes inherit Stream class , To provide the ability to read from a specific source / The function of writing bytes :
FileStream: Read bytes from or write bytes to a physical file , Whether it is .txt,.exe,.jpg Or any other document .FileStream Derive from Stream class .
MemoryStream: MemoryStream Read or write bytes stored in memory .
BufferedStream: BufferedStream From the other Stream Read or write bytes , To improve some I / O Performance of operation .
NetworkStream: NetworkStream Read or write bytes from a network socket .
PipeStream: PipeStream Read or write bytes from different processes .
CryptoStream: CryptoStream Used to link a data stream to a cryptographic transformation .


Two 、C# IO Stream Readers and writers
1. character string Readers and writers
StreamReader:StreamReader Is a helper class , Used to convert bytes to characters from by using encoded values Stream Read character . It can be used from different streams ( for example FileStream,MemoryStream etc. ) Read string from ( character ).
StreamWriter:StreamWriter Is a helper class , Used to write a string to by converting characters to bytes Stream. It can be used to write strings to different streams , for example FileStream,MemoryStream etc. .
2. Binary system Readers and writers
BinaryReader:BinaryReader Is a helper class for reading raw data types from bytes .
BinaryWriter:BinaryWriter Write primitive types in binary .

The image above shows ,FileStream Read bytes from physical file , then StreamReader Read the string by converting these bytes to a string . Again ,StreamWriter Get a string and convert it to bytes , And then write FileStream, then FileStream Write bytes to a physical file . therefore ,FileStream Processing bytes ,StreamReader and StreamWriter Processing strings .
3、 ... and 、 Often tidy up
Stream Is an abstract class for transferring bytes from different sources . It is the base class for all other classes , These other classes read bytes / Write to different sources .
FileStream Class provides byte read and write functions for physical files .
The reader / writer class provides the slave stream class (FileStream,MemoryStream etc. ) The function of reading bytes and converting bytes into appropriate encoding .
StreamReader By converting bytes to strings , Provides an auxiliary method to get information from FileStream Read string from .StreamWriter Provides a helper method , You can write a string to by converting it to bytes FileStream.
more :
C# IO Stream flow ( One ) Basic concepts _ The basic definition
C# Array grouping _C# The data packet _C# Linq Use groups to organize
C# Available types in _ Type not available _C# Double question mark _C# Question mark point _C# null It's not equal to
边栏推荐
- Tensorrt PB to UF problem
- Summary of common terms and knowledge in SMT chip processing industry
- 1-11Vmware虚拟机常见的问题解决
- Solution to component stele in SMT chip processing
- Installing redis on Linux
- 信号处理函数内必须使用可重入函数
- Setting up a cluster environment under Linux (2) -- installing MySQL under Linux
- Causes and solutions to the phenomenon of PCBA monument in SMT patch processing
- "Method not allowed", 405 problem analysis and solution
- DBCA silent installation and database building
猜你喜欢

Idea kotlin version upgrade

Camkiia et gcamp6f sont - ils les mêmes?

1-10vmware builds customized network architecture

Cloud rendering and Intel jointly create the "core" era of cloud rendering

After being trapped by the sequelae of the new crown for 15 months, Stanford Xueba was forced to miss the graduation ceremony. Now he still needs to stay in bed for 16 hours every day: I should have e

《SQL优化核心思想》

鼠标拖拽围绕某个物体旋转展示
![Mysql5.7 is in the configuration file my Ini[mysqld] cannot be started after adding skip grant tables](/img/b2/2b87b3cea1422e2a860f5e0e7dcc40.png)
Mysql5.7 is in the configuration file my Ini[mysqld] cannot be started after adding skip grant tables

每日刷题记录 (四)
![[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code](/img/a9/4fbe82fc77712f2e10119aacb99143.png)
[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
随机推荐
事物/现象/事情/东西/情况/表象
Idea set the template of mapper mapping file
darkent2ncnn出错
Logstash discards log data that does not match the file name exactly
1-11solutions to common problems of VMware virtual machine
Xiaohongshu microservice framework and governance and other cloud native business architecture evolution cases
Solution to SMT grape ball phenomenon
STL tutorial 5-basic concepts of STL and the use of string and vector
使用VS2022編譯Telegram桌面端(tdesktop)
Is camkiia the same as gcamp6f?
leetcode.14 --- 最长公共前缀
实现异步的方法
Law and self-regulation in the meta universe
Compile the telegraph desktop side (tdesktop) using vs2022
Installing redis on Linux
Comprehensive introduction to Simulink solver
mtb13_Perform extract_blend_Super{Candidate(PrimaryAlternate)_Unique(可NULL过滤_Foreign_index_granulari
Redisson 3.17.4 release
性能领跑云原生数据库市场!英特尔携腾讯共建云上技术生态
DNS review