字符数组转换为字符串,字符串转换为字节


字符数组转换为字符串,字符串转换为字节,例子如下

                        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