c# - How to change bits inside Short -
i have short-variable in c# , want change specific bit. how can easiest way?
do mean this?
public static short setbit(short input, int bit) { return (short) (input | (1 << bit)); } public static short clearbit(short input, int bit) { return (short) (input & ~(1 << bit)); }
you make them extension methods if want to.
Comments
Post a Comment