Home »
VB.Net »
VB.Net Programs
VB.Net program to perform BITWISE XOR operation
By Nidhi Last Updated : November 16, 2024
BITWISE XOR Operator in VB.Net
Here, we will perform a BITWISE XOR operation between two integer variables and print the result.
VB.Net code to demonstrate the example of BITWISE XOR Operator
The source code to perform BITWISE XOR operation is given below. The given program is compiled and executed successfully.
'VB.Net program to perform "bitwise xor" operation.
Module Module1
Sub Main()
Dim num1 As Integer = 6
Dim num2 As Integer = 2
Dim res As Integer = 0
res = num1 Xor num2
Console.WriteLine("Result: {0}", res)
Console.ReadLine()
End Sub
End Module
Output:
Result: 4
Explanation:
In the above program, we created a module Module1 that contains a function Main(). In the Main() function, we created three local variables num1, num2, and res that are initialized with 5, 2, and 0 respectively.
res = num1 Xor num2
Now evaluate the above expression.
res = num1 Xor num2
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.
At last, we printed the value of res on the console screen.
VB.Net Basic Programs »