How to use the bit operator in C #
This article Xiaobian for you to introduce in detail "how to use the bit operator in C#", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use the bit operator in C#" can help you solve your doubts. Let's follow the editor's way of thinking to learn new knowledge.
Example
Take a look at the following example for all the bit operators available in C#:
Using System
Namespace OperatorsAppl
{
Class Program
{
Static void Main (string [] args)
{
Int a = 60; / * 60 = 0011 1100 * /
Int b = 13; / * 13 = 0000 1101 * /
Int c = 0
C = a & b; / * 12 = 0000 1100 * /
Console.WriteLine (value of "Line 1-c is {0}", c)
C = a | b; / * 61 = 0011 1101 * /
Console.WriteLine (the value of "Line 2-c is {0}", c)
C = a ^ b; / * 49 = 0011 0001 * /
Console.WriteLine (the value of "Line 3-c is {0}", c)
C = ~ a; / *-61 = 1100 0011 * /
Console.WriteLine (value of "Line 4-c is {0}", c)
C = a 2; / * 15 = 0000 1111 * /
Console.WriteLine (value of "Line 6-c is {0}", c)
Console.ReadLine ()
}
}
}
When the above code is compiled and executed, it produces the following results:
Line 1-c value is 12Line 2-c value is 61Line 3-c value is 49Line 4-c value is-61Line 5-c value is 240Line 6-c value is 15 read here, this "how to use the bit operator in C #" article has been introduced, want to master the knowledge of this article also need to practice in order to understand, if you want to know more related content of the article, welcome to pay attention to the industry information channel.