0% found this document useful (0 votes)
9 views

WindowsForms_BitwiseOperations

The document provides instructions for creating a Windows Forms application that demonstrates bitwise operations (AND, OR, XOR) using C#. It includes the layout with three labels, four textboxes, and two buttons, along with the C# code to perform the operations and display results in both decimal and binary formats. The code handles user input from textboxes and updates the results accordingly when buttons are clicked.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

WindowsForms_BitwiseOperations

The document provides instructions for creating a Windows Forms application that demonstrates bitwise operations (AND, OR, XOR) using C#. It includes the layout with three labels, four textboxes, and two buttons, along with the C# code to perform the operations and display results in both decimal and binary formats. The code handles user input from textboxes and updates the results accordingly when buttons are clicked.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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 System.Windows.Forms;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e) // AND 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
}

private void button2_Click(object sender, EventArgs e) // OR 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
}
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
}
}
}

You might also like