Font oldFont;
Font newFont;oldFont = this.richTextBox1.SelectionFont;
bool checkState = ((Toolstripbutton1)sender).Checked;
if(!checkState)
{
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Italic);
}
else
{
newFont = new Font(oldFont, oldFont.Style | FontStyle.Italic);
}
.........oldFont.Style & ~FontStyle.Italic和oldFont.Style | FontStyle.Italic
这个是什么意思呀
它功能是判断后让字体Italic,但是不明上面那两句
Font newFont;oldFont = this.richTextBox1.SelectionFont;
bool checkState = ((Toolstripbutton1)sender).Checked;
if(!checkState)
{
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Italic);
}
else
{
newFont = new Font(oldFont, oldFont.Style | FontStyle.Italic);
}
.........oldFont.Style & ~FontStyle.Italic和oldFont.Style | FontStyle.Italic
这个是什么意思呀
它功能是判断后让字体Italic,但是不明上面那两句
去除斜体样式。oldFont.Style ¦ FontStyle.Italic
增加斜体样式。
&(与) xxxx就是去除?
那么~即是111011,任何一个数与111011按位与运算的结果是将倒数第三位的数值置零,即& ~FontStyle.Italic即是去除斜体样式。同理。