public  static void Login(string ss)
        {           byte[] mss = System.Text.Encoding.Default.GetBytes(ss);
            byte[] ms = new byte[4];
            ms[0] = 1;
            ms[1] = 32;
            byte c = (byte)(ms[0] + ms[1]+mss数组);
            Console.Write(c);
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            string sss = Console.ReadLine();
            Login(sss);
        }
如何保证数据不溢出,得出结果再转换成字节数组

解决方案 »

  1.   


            /// <summary>
            /// 合并两个字节数组
            /// </summary>
            /// <param name="byte1"></param>
            /// <param name="byte2"></param>
            /// <returns></returns>
            private static byte[] MergeBytes(byte[] byte1, byte[] byte2)
            {
                byte[] bs = new byte[byte1.Length + byte2.Length];
                Array.Copy(byte1, 0, bs, 0, byte1.Length);
                Array.Copy(byte2, 0, bs, byte1.Length, byte2.Length);
                return bs;
            }