To start, we look at the numbers 77 and 100. These are represented with bit patterns. We combine two values with bitwise OR, and print the result.
using System;
class Program
{
static void Main()
{
int a = 77;
int b = 100;
// Use bitwise OR.
int c = a | b;
// Display bits.
Console.WriteLine(
"{0} = {1}", GetIntBinaryString(a), a);
Console.WriteLine(
"{0} = {1}", GetIntBinaryString(b), b);
Console.WriteLine(
"{0} = {1}", GetIntBinaryString(c), c);
}
static string GetIntBinaryString(int value)
{
return Convert.ToString(value, 2).PadLeft(32, '0');
}
}
00000000000000000000000001001101 = 77
00000000000000000000000001100100 = 100
00000000000000000000000001101101 = 109