.NET streams, passing streams between objects, best practices (C#)

后端 未结 4 2143
温柔的废话
温柔的废话 2020-12-31 12:31

I\'m currently writing a little toy assembler in c# (going through the elements of computing systems book. Really good book by the way.)

The assembler takes an input

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 12:37

    If something else is using the stream after the assembler is done with it, the assembler shouldn't "own" the stream. The caller should either create a stream for the assembler (and subsequent modules) to use, or the assembler should return a new stream which it is then the caller's responsibility to close.

    It would be instructive to see some more details on what your program's architecture looks like and what methods we are discussing here.

提交回复
热议问题