Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey all,

Sorry for the somewhat confusing title, i don't know how to describe it differently.
Here is the problem that's been wrecking havoc on my brains the past days.

I need to compare 2 byte arrays with each other, this is quite simple.
But now i need to add 2 wildcards to one of the byte arrays.

The problem is how do i know i supposed to use the wildcard code instead of direct comparing.
Now if i could do something like (byte)256 is integer wildcard and (byte)257 is an character wildcard, but this is not possible.
The other idea was use null in the array so i know it's a wildcard and i can go from there but this is also not possible.

The only other idea i had is use an arraylist, and add a different datatype but this would require typeof() everytime, and the speed is the main focus of the application so i am trying to avoid this option.

Does anyone have any ideas?
Thanks allot!
Posted

You could

0) create a pair of dictionaries that hold the position and value of the wildcard positions (one dictionary for each array)

1) Plug a wildcard byte (say, "FF") to those positions

2) Perform the comparison

3) Replace the original values at their original positions from the dictionaries
 
Share this answer
 
Why didn't i think of that.

That the same as an assembly debugger breakpoint.
Just replace the original byte with CC and then restore the original byte.

Or in my case if the byte is 0xFF check it's a wildcard or a normal byte,
Simple yet genius.

Thanks!!
 
Share this answer
 

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