使用C#将字符串转化成流,将流转换成字符串,代码如下:

using System.IO;
using System.Text;
namespace CSharpConvertString2Stream
{    
 class Program    
 {               
       static void Main( string[] args )
        {            
            string str = "Testing 1-2-3";             //convert string 2 stream            
            byte[] array = Encoding.ASCII.GetBytes(str);            
            MemoryStream stream = new MemoryStream(array);             //convert stream 2 string      
            StreamReader reader = new StreamReader(stream);
            string text = reader.ReadToEnd();
            Console.WriteLine(text); 
            Console.ReadLine(); 
       }  
  }
}

 

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2021-07-24
  • 2021-09-19
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2021-07-22
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案