C#的
有两串字符串.或者更多.
1)01000011
2)01001100
如何把他们合起来合变成01001111
也就是说.两串字符串合并后,如果两串对应位置的数字,
如果有一个是1合并会一定会是1.
两个1也是1.如果其中一个是0一个是1那还是1高手麻烦帮一下忙.

解决方案 »

  1.   

    长度长的为A。
    短的为B。
    遍历B,如果B[i]==1,则A[i]=1;就行了。
      

  2.   

       string _Temp1 = "01000011";
               string _Temp2 = "01001100";           byte _TempByte1 = Convert.ToByte(_Temp1, 2);
               byte _TempByte2 = Convert.ToByte(_Temp2, 2);           byte _Byte = (byte)(_TempByte1 | _TempByte2);           string _Text = Convert.ToString(_Byte, 2).PadLeft(8,'0');
      

  3.   

    string s1 = "01000011";
    string s2 = "01001100";
    string s3 = Convert.ToString(Convert.ToInt32(s1, 2) | Convert.ToInt32(s2, 2),2).PadLeft(8,'0');
    Response.Write(s3);
      

  4.   

    string str1 = "01000011";
    string str2 = "01001100";
    string result = Convert.ToString(Convert.ToInt32(str1, 2) | Convert.ToInt32(str2, 2),2).PadLeft(8,'0');
      

  5.   

    这是按位或运算 C#中有按位或运算 
    把数字表示成二进制数 后面加B(bit)进行按位运算 就行了
    01000011B | 01001100B
    更多个就继续按位或 |
    同样的能使用按位与 &
      

  6.   

    事实上这样就行了
    Convert.ToInt32("01000011",2) | Convert.ToInt32("01001100",2); 就可以了 
    如果有三个就
    Convert.ToInt32("01000011",2) | Convert.ToInt32("01001100",2) | Convert.ToInt32("010000100",2);  
    四五六七八个类推
      

  7.   

    下面方法可能繁了点,但是可行
    using System;
    using System.Collections.Generic;
    using System.Text;namespace TempApp
    {
        class Program
        {
            /// <summary>
            /// 
            /// </summary>
            /// <param name="args"></param>
            ///         public void comstring(string temp_1,string temp_2)
            { 
            
            
                int[] tp_1 = new int[temp_1.Length];
                int[] tp_2 = new int[temp_2.Length]; 
                for (int i = 0; i < temp_1.Length; i++)
                {
                    tp_1[i] = (int)temp_1[i];
                 
                 
                }
                for (int j = 0; j < temp_2.Length; j++)
                {
                    tp_2[j] = (int)temp_2[j];
                      
                }
                
               int[] tp_3 = new int[temp_2.Length]; 
                for (int p = 0; p < tp_1.Length; p++)
                { 
                  if(tp_1[p]==tp_2[p])
                  {
                      tp_3[p] = tp_1[p];
                  
                  }
                  if (tp_1[p] > tp_2[p])
                  {
                      tp_3[p] = tp_1[p];
                  }
                  else 
                  {
                      tp_3[p] = tp_2[p];
                  }
                }
                char[] aa = new char[tp_3.Length];
                for (int y = 0; y < tp_3.Length; y++)
                {
                    aa[y] = (char)tp_3[y];
                    Console.WriteLine(aa[y]);
                } 
            }        static void Main(string[] args)
            {
              
                  string temp_1 = "01011111";
                string temp_2 = "01001100";
                Program pm = new Program();
                pm.comstring(temp_1, temp_2);
      
             }        }
        }
    }
      

  8.   

            public string ByteOr(string str1, string str2)
            {
                byte byte1 = Convert.ToByte(str1, 2);
                byte byte2 = Convert.ToByte(str2, 2);
                byte _Byte = (byte)(byte1 | byte2);           return Convert.ToString(_Byte, 2).PadLeft(8, '0');
            }
      

  9.   

    教你个最苯的办法
    bitarry 数组 来实现
     然后一个个提取出来对应的 用 * 方法来解决具体的话自己去研究给你写出代码就没意思了 要添加 birarry 命名空间 
      

  10.   


    MS这个方法很管用,不知道试过没有?
    转完以后应该再Convert.ToString为二进制显示
      

  11.   

    help http://topic.csdn.net/u/20090216/17/489e6eb2-cb73-4126-9137-a95fd161e463.html