How do I generate a stream from a string?

后端 未结 12 872
春和景丽
春和景丽 2020-11-22 14:29

I need to write a unit test for a method that takes a stream which comes from a text file. I would like to do do something like this:

Stream s = GenerateStre         


        
12条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 15:36

    I think you can benefit from using a MemoryStream. You can fill it with the string bytes that you obtain by using the GetBytes method of the Encoding class.

提交回复
热议问题