title: Bitwise operations on strings - 1440 characters length
body: <p>How can i make bitwise operations on strings at c# </p>
  
  <p>example</p>
  
  <pre><code>string sr1="0101110";
  string sr2="1101110";
  
  sr1 &amp; sr2="0101110";
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sr1 | sr2="1101110";
  </code></pre>
  
  <p>How can i make such comparison ?</p>
  
  <p><strong>Notice string lengths are fixed 1440 characters</strong></p>
  
  <p>Here my dirty solution</p>
  
  <pre><code>    private string compareBitWiseAnd(string sr1, string sr2)
      {
          char[] crArray1 = sr1.ToCharArray();
          char[] crArray2 = sr2.ToCharArray();
          StringBuilder srResult = new StringBuilder();
  
          for (int i = 0; i &lt; crArray1.Length; i++)
          {
              if (crArray1[i] == crArray2[i])
              {
                  srResult.Append(crArray1[i]);
              }
              else
              {
                  srResult.Append('0');
              }
          }
  
          return srResult.ToString();
      }
  
      private string compareBitWiseOr(string sr1, string sr2)
      {
          char[] crArray1 = sr1.ToCharArray();
          char[] crArray2 = sr2.ToCharArray();
          StringBuilder srResult = new StringBuilder();
  
          for (int i = 0; i &lt; crArray1.Length; i++)
          {
              if (crArray1[i] == '1' || crArray2[i] == '1')
              {
                  srResult.Append("1");
              }
              else
              {
                  srResult.Append('0');
              }
          }
  
          return srResult.ToString();
      }
  </code></pre>