c# MemoryStream vs Byte Array

后端 未结 3 1901
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 00:07

I have a function, which generates and returns a MemoryStream. After generation the size of the MemoryStream is fixed, I dont need to write to it anymore only output is requ

3条回答
  •  借酒劲吻你
    2020-12-14 00:45

    Use a byte[] because it's a fixed sized object making it easier for memory allocation and cleanup and holds relatively no overhead - especially since you don't need to use the functions of the MemoryStream. Further you want to get that stream disposed of ASAP so it can release the possible unmanaged resources it may be using.

提交回复
热议问题