형변환 (2) 썸네일형 리스트형 char[ ] -> string, string -> char[ ] 아래와 같이 char배열에서 string으로 string에서 char로 형변환 할 수 있다. 보너스는 char 배열 넘기기~ (복사해서 넘긴다. 주소를 넘기려면 ref를 사용) string str = "12345"; char[] temp_str; temp_str = str.ToCharArray(); // string -> char [] Rcv_Char_arr(temp_str); protected void Rcv_Char_arr(char[] arr) { string str = new string(arr); // char[] -> string } C#에서 고정 크기 구조체 사용과 바이트 배열로 형 변환 public struct Test_Struct_t { public byte var1; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public char[] str; // (1) //public char[] str; // (2) } public class AP_DB_Cmd_Box : AP_DB_Common { // protected members Test_Struct_t test_struct; int length; byte[] cmd_tmp; IntPtr cmd_ptr; public AP_DB_Cmd_Box() : base() { test_struct.str = new char[10]; // 꼭 해줘야한다. 안그럼 아래에서 에러 test_struct.va.. 이전 1 다음