字符數組轉換為字符串,字符串轉換為字節


字符數組轉換為字符串,字符串轉換為字節,例子如下

                        char[] ch = new char[str1.Length];
                        for (int i = 0; i < str1.Length; i++)
                        {
                            ch[i] = str1[i];
                        }
                        byte[] data = new byte[str1.Length / 2 + 3];
                        for (int i = 0; i < str1.Length; i = i + 2)
                        {
                            string str2 = ch[i] + "" + ch[i + 1];
                            int int1 = Convert.ToInt32(str2, 16);
                            data[i / 2] = (Byte)int1;
                        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM