I have two bitfields, one of 8 bits and one of 4 bits.
[Flags]
public enum Bits1 {
A = 1,
B = 2,
C = 4,
D = 8,
E = 16,
F = 32,
G = 64,
H = 128
}
[Flags]
public enum Bits2 {
I = 1,
J = 2,
K = 4,
L = 8
}
I need to map the bits in Bits1 to Bits2, like this:
Bits2 = Map(Bits1)
For example, supposing that A and C map to J, B maps to nothing, and D maps to I in the mapping, ABCD(value of 13), after going through the map function, returns IJ(value of 3).
The map should be able to be set and changed programmatically as needed. This sounds like something a Dictionary might be able to do, but I'm not sure how to set it up. What would be the best way to accomplish this in C#?