WindowsForms_BitwiseOperations
WindowsForms_BitwiseOperations
Create three labels (Number 1, Number 2, Number 3), four textboxes, and two buttons. Do not
This C# code demonstrates bitwise operations (AND, OR, XOR) using Windows Forms.
It takes input from two textboxes, performs the selected operation, and displays the result in decimal
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
textBox3.Text = result.ToString();
textBox4.Text = Convert.ToString(result, 2); // Binary representation
}
textBox3.Text = result.ToString();
textBox4.Text = Convert.ToString(result, 2); // Binary representation
}
private void button3_Click(object sender, EventArgs e) // XOR operation
{
int num1 = int.Parse(textBox1.Text);
int num2 = int.Parse(textBox2.Text);
int result = num1 ^ num2;
textBox3.Text = result.ToString();
textBox4.Text = Convert.ToString(result, 2); // Binary representation
}
}
}