CopyPastehas never been so tasty!

How to perform And Operation on byte in C#.net

by anonymous

  • 0
  • 0
  • 0
84 views

How to perform And Operation on byte in C#.net

Byte data type:

 

In C# byte data type represents an 8-bit unsigned integer.

 

Perform and operation on Byte:

 

Perform and operation on Byte. To perform and operation on byte in C#.net is very simple C#.net provides a function Byte.Parse(). Which convert string representation of a number to its system.Byte equivalent. And then and operation can be operated on it.

 

To demonstrate make a window from application, and drag a button on the form

 

Now write the following code on the Button Click event.

 

Code:

private void button1_Andoperation_Click(object sender, EventArgs e) {

            byte mask = 0xFE;

            Byte byteValue = Byte.Parse("12");

            Console.WriteLine("{0} And {1} = {2}", byteValue, mask, byteValue & mask);

}

Now write the following code in Form load event.

 

Code:

        private void Form1_Load(object sender, EventArgs e){

            this.Text = "Coding villa Byte And Operation";

        }

This is a simple article that tells you how to perform And operation on byte in C#.net.

Add A Comment: