[問題] byte array 如何轉 char array ??

看板C_Sharp (C#)作者 (阿隆西)時間20年前 (2005/03/07 22:58), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/3 (看更多)
int i; byte[] byteAry = {65, 66, 67}; char[] charAry = new char[3]; for( i=0; i<3; i++ ) charAry[i] = Convert.ToChar( byteAry[i] ); Console.WriteLine( byteAry ); // output : System.byte [] Console.WriteLine( charAry ); // output : ABC 小弟寫了上述程式,有2個問題向大家討教: Q1 : for( i=0; i<3; i++ ) charAry[i] = Convert.ToChar( byteAry[i] ); 請問有沒有function,直接一次接 byteAry to charAry ?? Q2 : Console.WriteLine( byteAry ); // output : System.byte [] 有沒有function讓其輸出為 ABC ?? 謝謝大家。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.138.64.169

219.84.81.23 03/08, , 1F
這個問題我也想問,雖然有自己寫,但效率不知?
219.84.81.23 03/08, 1F
文章代碼(AID): #12B6lvuw (C_Sharp)
文章代碼(AID): #12B6lvuw (C_Sharp)