假设我有以下内容
int susan = 2; //0010
int bob = 4; //0100
int karen = 8; //1000
Run Code Online (Sandbox Code Playgroud)
我将10(8 + 2)作为参数传递给方法,我想将其解码为苏珊和卡伦
我知道10是1010
但是我如何做一些逻辑来查看是否检查了特定位
if (condition_for_karen) // How to quickly check whether effective karen bit is 1
Run Code Online (Sandbox Code Playgroud)
现在,我能想到的是检查我通过的号码是否正确
14 // 1110
12 // 1100
10 // 1010
8 // 1000
Run Code Online (Sandbox Code Playgroud)
当我在我的真实场景中拥有更多的实际比特时,这似乎是不切实际的,使用掩码来检查我是否满足karen条件的更好方法是什么?
我可以想到向左移动然后向后移动然后向右移动然后移回到除了我感兴趣的那个之外的其他位置,但这似乎也过于复杂.
如何将多种字体样式应用于文本?
System.Drawing.Font MyFont = new System.Drawing.Font(
thisTempLabel.LabelFont,
((float)thisTempLabel.fontSize),
FontStyle.Bold + FontStyle.Italic, // + obviously doesn't work, but what am I meant to do?
GraphicsUnit.Pixel
);
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!