Windows Forms Application Instructions
Create three labels (Number 1, Number 2, Number 3), four textboxes, and two buttons. Do not
change their names in properties.
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
and binary format.
using System;
using [Link];
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) // AND operation
{
int num1 = [Link]([Link]);
int num2 = [Link]([Link]);
int result = num1 & num2;
[Link] = [Link]();
[Link] = [Link](result, 2); // Binary representation
}
private void button2_Click(object sender, EventArgs e) // OR operation
{
int num1 = [Link]([Link]);
int num2 = [Link]([Link]);
int result = num1 | num2;
[Link] = [Link]();
[Link] = [Link](result, 2); // Binary representation
}
private void button3_Click(object sender, EventArgs e) // XOR operation
{
int num1 = [Link]([Link]);
int num2 = [Link]([Link]);
int result = num1 ^ num2;
[Link] = [Link]();
[Link] = [Link](result, 2); // Binary representation
}
}
}