반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
static void Main(string[] args)
{
        //
        // TODO: 여기에 응용 프로그램을 시작하는 코드를 추가합니다.
        string str = "가나다"
        char[] charArray = str.ToCharArray(); 
        Console.WriteLine("Char Array"); 
//        for(int i=0;i<charArray.Length;i++) 
//                Console.WriteLine((int)charArray[i]); 
        foreachchar a in charArray )
                Console.WriteLine("{0}", (int)a);
 
Console.WriteLine(); 
 
byte[] byteArray = System.Text.ASCIIEncoding.Default.GetBytes(str); 
         
Console.WriteLine("Byte Array"); 
//        for(int i=0;i<byteArray.Length;i++) 
//                Console.WriteLine(byteArray[i]); 
        foreachchar a in byteArray )
                Console.WriteLine("{0}", (int)a);
}
cs



출처 : http://www.hoons.net/board/cshaptip/content/419


반응형

'프로그래밍 > C#' 카테고리의 다른 글

C# 바이트 파일 읽기  (0) 2017.05.26
C# 바이트 파일 저장  (0) 2017.05.26
C# string to hex  (0) 2017.05.24
C# byte를 헥사값으로 출력  (0) 2017.05.22
C# 보안 액세스 거부 문제 해결  (2) 2017.05.22

+ Recent posts