Home >>VB.Net Programs >VB.Net program to perform BITWISE XOR operation

VB.Net program to perform BITWISE XOR operation

Write a VB.Net program to perform BITWISE XOR operation

Here, between two integer variables, we will perform a BITWISE XOR operation and print the result.

Program

Below is the source code for performing the BITWISE XOR operation. The program given is compiled and successfully executed.

Example


Module Module1
    Sub Main()
        Dim x As Integer = 6
        Dim y As Integer = 2
        Dim res As Integer = 0
        res = x Xor y
        Console.WriteLine("Result: {0}", res)
        Console.ReadLine()
    End Sub
End Module

Output:
Result: 4

Explanation:

We generated a Module1 module in the above program that contains the function Main (). Three local variables x, y, and res, initialized with 5, 2, and 0 respectively, were generated in the Main() function.

res = x Xor y

Now evaluate the above expression.

res = x Xor y
res = 6 Xor 2
The binary equivalent of 6 is 110.
The binary equivalent of 2 is 010.
Then
110
010
====
010
That is 4.

Finally, on the console screen, we printed the value res.


No Sidebar ads