码迷,mamicode.com
首页 > Windows程序 > 详细

string与stream的相互转换(C#)

时间:2014-11-19 12:30:02      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   os   sp   on   div   log   

string与stream的相互转换

 1 string test = “This is string″;  
 2   
 3 // convert string to stream  
 4 MemoryStream stream = new MemoryStream();  
 5 StreamWriter writer = new StreamWriter( stream );  
 6 writer.Write( test );  
 7 writer.Flush();  
 8   
 9 // convert stream to string  
10 stream.Position = 0;  
11 StreamReader reader = new StreamReader( stream );  
12 string text = reader.ReadToEnd();  

 

string与stream的相互转换(C#)

标签:style   blog   io   color   os   sp   on   div   log   

原文地址:http://www.cnblogs.com/coldfishing/p/4107788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!