public abstract Read ( [ buffer, int offset, int count ) : int | ||
buffer | [ | |
offset | int | |
count | int | |
return | int |
FileStream fileStream = new FileStream("path/to/file", FileMode.Open, FileAccess.Read); byte[] buffer = new byte[1024]; int bytesRead = fileStream.Read(buffer, 0, buffer.Length);
MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("Hello World")); byte[] buffer = new byte[1024]; int bytesRead = memoryStream.Read(buffer, 0, buffer.Length);In this example, we create a memory stream from a string using the Encoding class. We then create a buffer with a size of 1024 bytes and call the Read method to read bytes from the memory stream into the buffer. The number of bytes read is stored in the bytesRead variable. Package library: System.IO.MemoryStream
public abstract Read ( [ buffer, int offset, int count ) : int | ||
buffer | [ | |
offset | int | |
count | int | |
return | int |