Method StringFromStreamOrNull
StringFromStreamOrNull(Stream?, Encoding?)
Reads a string from the specified stream using the specified encoding. Returns null if the stream is null or if an error occurs during reading.
public static string? StringFromStreamOrNull(Stream? stream, Encoding? encoding = null)
Parameters
stream
StreamThe stream to read from. If null, the method returns null.
encoding
EncodingThe encoding to use for reading the stream. Optional. If not specified, UTF8 is used.
Returns
- string
The string read from the stream, or null if the stream is null or an error occurs.