c# - how to retrieve back values from an ORed flag -
c# - how to retrieve back values from an ORed flag -
assume im dealing createfilea
i have
public const generic_all int32 = &h10000000 public const generic_read int32 = &h80000000 public const generic_write int32 = &h40000000 public const generic_execute int32 = &h20000000
thus means if need read , write do
generic_read | generic_write = 0c0000000h
how api reverse or operation know flags contains ?, in words assume got value "0c0000000h" , need know accesses contains, operations should on number ?
my point if have 100 flags , ored/anded them sick end complicated number, how retrieve flags used compose number ?
the binary , operation can used test individual bits (aka flags).
for instance
bool b = (value & generic_read) != 0;
evaluates true if generic_read ored value previously, regardless of other flags have been combined.
if doesn't explain enough, perhaps http://en.wikipedia.org/wiki/bitwise_operation#and help.
c# c++ c bitflags
Comments
Post a Comment