■ StreamWriter 클래스를 사용해 문자열을 스트림으로 변환하기

------------------------------------------------------------------------------------------------------------------------

using System;

using System.IO;

using System.Text;

 

string test = "ab";

 

MemoryStream stream = new MemoryStream();

 

StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);

 

writer.Write(test);

 

writer.Flush();

 

stream.Position = 0;

 

foreach(byte value in stream.ToArray())

{

    Console.WriteLine(value.ToString("x"));

}

 

/*

ef

bb

bf

61 : a

62 : b

*/

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG