What are the default values ​​for StreamReader?

I need to use this constructor public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen)to set leaveOpento true. And for this I need to set other parameters as well ( Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize). I want to use StreamReader, since I do not want to give some random values. What are the default values ​​for these options?

By the way, I know what I can use StreamReaderwithout using. And the GC will get rid of it without touching the stream.

+4
source share
4 answers

The default values ​​are as follows:

  • Encoding: Encoding.UTF8
  • detectEncodingFromByteOrderMarks: true
  • DefaultBufferSize: 1024

, Reference Source

+11

Encoding.UTF8, true 1024 .

: .

, Encoding Encoding.UTF8, bufferSize 1024, MSDN, detectEncodingFromByteOrderMarks .

+2

, .

, :

  • detectEncodingFromByteOrderMarks
  • DefaultBufferSize - 1024 4096
  • - Encoding.UTF8
  • leaveOpen false

DefaultBufferSize 4096 .

+1

Stream streamyou need to go on reading. Encoding encodingThe default value is AFAIK UTF-8. int bufferSizeis at least 128 characters. bool leaveOpenby default false, and it will call Dispose()after reading the stream

The documentation clearly said.

0
source

Source: https://habr.com/ru/post/1649128/


All Articles