Do I need to do StreamWriter.flush()?

前端 未结 2 728
说谎
说谎 2021-02-05 03:29

Suppose this C# code:

using (MemoryStream stream = new MemoryStream())
{
    StreamWriter normalWriter = new StreamWriter(stream);
    BinaryWriter binaryWriter          


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 03:56

    Update

    Nevermind this answer, I got confused with the writers...


    1. No, the order will be preserved (update: maybe not). Flush is useful/needed in other situations, though I can't remember when.
    2. I think so, using makes sure everything cleans up nicely.

提交回复
热议问题