当前位置:网站首页>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
边栏推荐
- 7. common instructions (Part 2): common operations of v-on, v-bind and V-model
- Deploy Ogg on the same machine and test
- How ASA configures port mapping and pat
- Compile the telegraph desktop side (tdesktop) using vs2022
- QT excellent open source project 9: qtox
- DPVS fullnat mode deployment
- Cloud rendering and Intel jointly create the "core" era of cloud rendering
- When installing PSU /usr/bin/ld:warning: -z lazload ignore
- Logstash discards log data that does not match the file name exactly
- 什么是微服务
猜你喜欢

11.1.1 overview of Flink_ Flink overview

CaMKIIa和GCaMP6f是一样的嘛?

Permission design = function permission + Data permission

什么是微服务

被新冠后遗症困住15个月后,斯坦福学霸被迫缺席毕业典礼,现仍需每天卧床16小时:我本该享受20岁的人生啊...

Display unassigned virtual address after easyconnect connection

每日刷题记录 (四)

1-11solutions to common problems of VMware virtual machine

SSL unresponsive in postman test

渗透工具-Burpsuite
随机推荐
实现异步的方法
Qt之自定义带游标的QSlider
Types of feeder and how to work
yolov5 提速多GPU训练显存低的问题
7. common instructions (Part 2): common operations of v-on, v-bind and V-model
Cloud rendering and Intel jointly create the "core" era of cloud rendering
anchor free dection简介
机器视觉:照亮“智”造新“视”界
mtb13_Perform extract_blend_Super{Candidate(PrimaryAlternate)_Unique(可NULL过滤_Foreign_index_granulari
Setting up a cluster environment under Linux (2) -- installing MySQL under Linux
The development context of Ba Kong Yuan universe industry
删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?
1-10Vmware构建自定义的网络架构
Why do we need to make panels and edges in PCB production
Circuit board edge removal - precautions for V-CUT splitting machine
渲云携手英特尔,共创云渲染“芯”时代
Multi-Instance Redo Apply
[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
Idea view unit test coverage
"Seamless" deployment of paddlenlp model based on openvinotm development kit