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

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

ruby - Nesting modules inside of a Rails eninge gem -

Eclipse formatter for java ending braces -