TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jonathan Crispe
NA
46
48.6k
How to use binary operation
Oct 21 2011 1:52 AM
I was able to convert Hex values to binary,
but i can't figure out how to calculate the 2 16bit-binary value: An example shown below.
public partial class Form1 : Form
{
uint byhex1 = 0;
uint byhex2 = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void BTN_operation_Click(object sender, EventArgs e)
{
if (RB_andgate.Checked)
{
BTN_operation.Text = "&";
byhex1 = Convert.ToUInt16(TXB_hexvalue1.Text, 16);
LBL_binary1.Text = Convert.ToString(byhex1, 2).PadLeft(16, '0');
byhex2 = Convert.ToUInt16(TXB_hexvalue2.Text, 16);
LBL_binary2.Text = Convert.ToString(byhex2, 2).PadLeft(16, '0');
LBL_totalhex.Text = "0 X " + (byhex1 & byhex2).ToString("X4");
}
if (RB_orgate.Checked)
{
BTN_operation.Text = "|";
byhex1 = Convert.ToUInt32(TXB_hexvalue1.Text, 16);
LBL_binary1.Text = Convert.ToString(byhex1, 2).PadLeft(16, '0');
byhex2 = Convert.ToUInt32(TXB_hexvalue2.Text, 16);
LBL_binary2.Text = Convert.ToString(byhex2, 2).PadLeft(16, '0');
LBL_totalhex.Text = "0 X " + (byhex1 | byhex2).ToString("X4");
}
if (RB_xorgate.Checked)
{
BTN_operation.Text = "^";
byhex1 = Convert.ToUInt32(TXB_hexvalue1.Text, 16);
LBL_binary1.Text = Convert.ToString(byhex1, 2).PadLeft(16, '0');
byhex2 = Convert.ToUInt32(TXB_hexvalue2.Text, 16);
LBL_binary2.Text = Convert.ToString(byhex2, 2).PadLeft(16, '0');
LBL_totalhex.Text = "0 X " + (byhex1 ^ byhex2).ToString("X4");
}
}
}
how to put an exception just like in picture below in my code?
Reply
Answers (
2
)
Jagged Array in C#
Get the name of the com port and the devices connected to it