BinaryWriter.Write Method (String)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Writes a length-prefixed string to this stream in the current encoding of the BinaryWriter, and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.String
The value to write.
| Exception | Condition |
|---|---|
| IOException | An I/O error occurs. |
| ArgumentNullException | value is null. |
| ObjectDisposedException | The stream is closed. |
A length-prefixed string represents the string length by prefixing to the string a single byte or word that contains the length of that string. This method first writes the length of the string as a UTF-7 encoded unsigned integer, and then writes that many characters to the stream by using the BinaryWriter instance's current encoding.