Click here to Skip to main content
16,013,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey all
can you please help me in xoring in vb.net
i wanna xor these values
8f xor 33 xor cc xor 6a =1a
43 xor 19 xor 57 xor 39 =34
ae xor c6 xor 40 xor 2d =05
1a xor 49 xor 8b xor 6b =b3

Thanks in advance
Posted

1 solution

Try it this way

VB
dim x as integer = (((8f xor 33) xor cc) xor 6a)


If the number of values is variable, you could write a method:

VB
public Function XOrStack(values as integer()) as integer
    Dim result as integer = 0
    if (values.Length > 0) then
        foreach (value as integer in values)
            result = result Xor value
        Next
    end if
    return result
End Function


I'm a C# guy, so the code above may need tweaking.
 
Share this answer
 
v2
Comments
Nish Nishant 19-Jan-11 10:53am    
Are you sure the brackets are needed?
#realJSOP 24-Jan-11 15:53pm    
They probably aren't, but I'm a scope-aholic. :)
Nish Nishant 19-Jan-11 10:54am    
The result of multiple XOR operations don't really change if you reorder the XOR-ing via brackets. That's why I am puzzled as to why brackets are needed here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900