StreamReader vs BinaryReader?

后端 未结 1 1368
花落未央
花落未央 2020-12-02 14:39

Both StreamReader and BinaryReader can be used to get data from binary file ( for example )

BinaryReader :

   usi         


        
相关标签:
1条回答
  • 2020-12-02 14:59

    Both StreamReader and BinaryReader can be used to get data from binary file

    Well, StreamReader can be used to get text data from a binary representation of text.

    BinaryReader can be used to get arbitrary binary data. If some of that binary data happens to be a representation of text, that's fine - but it doesn't have to be.

    Bottom line:

    • If the entirety of your data is a straightforward binary encoding of text data, use StreamReader.
    • If you've fundamentally got binary data which may happen to have some portions in text, use BinaryReader

    So for example, you wouldn't try to read a JPEG file with StreamReader.

    0 讨论(0)
提交回复
热议问题