使用英语阅读

通过


MemoryStream.WriteByte(Byte) 方法

定义

将一个字节写入当前位置上的当前流。

public:
 override void WriteByte(System::Byte value);
public override void WriteByte (byte value);
override this.WriteByte : byte -> unit
Public Overrides Sub WriteByte (value As Byte)

参数

value
Byte

要写入的字节。

例外

流不支持写入。 有关其他信息,请参见 CanWrite

- 或 -

当前位置位于流的末尾,而且容量不能被修改。

当前流已关闭。

示例

此代码示例是为 MemoryStream 类提供的一个更大示例的一部分。

// Write the second string to the stream, byte by byte.
count = 0;
while ( count < secondString->Length )
{
   memStream->WriteByte( secondString[ count++ ] );
}
// Write the second string to the stream, byte by byte.
count = 0;
while(count < secondString.Length)
{
    memStream.WriteByte(secondString[count++]);
}
' Write the second string to the stream, byte by byte.
count = 0
While(count < secondString.Length)
    memStream.WriteByte(secondString(count))
    count += 1
End While

注解

此方法重写 WriteByte

除了 MemoryStream 使用 byte[] 参数构造的 ,在 末尾的 MemoryStream 写入操作将展开 MemoryStream

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

另请参阅