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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -