请各位熟悉的朋友帮忙解释一下
解决方案 »
- 在内存中操作DataTable后如何更新到数据库
- InvalidArgument=“0”的值对于“index”无效。 参数名: index
- C# Winform 内部控件移动设计问题
- 问一个关于类继承的问题?
- gridview 局部刷新
- 使用IList实现了一个Collection的时候发现每次进行list添加时会将原有的list重新添加一次
- C# 求助 如何 获得 datagridview 第一列 中值为 ”123“ 的行号
- 在CSS之中,id前面紧加一个DIV是什么意思,起什么作用,如 div#placard
- C# htmlselect
- 请问,C#.net如何访问xml,在线等待
- C#串行端口通信问题
- ■■★有经验者请进:有关C#开发嵌入式系统!嵌入式开发必看!
& 运算符既可作为一元运算符也可作为二元运算符。一元 & 运算符返回操作数的地址
为整型和 bool 类型预定义了二进制 & 运算符。对于整型,& 计算操作数的逻辑按位“与”。对于 bool 操作数,& 计算操作数的逻辑“与”;也就是说,当且仅当两个操作数均为 true 时,结果才为 true。 & 运算符计算两个运算符,与第一个操作数的值无关。
呵呵,如果FontStyle是个加了[Flag]的枚举,这还真是个好办法。楼主先去了解一下Flag特性才好理解这个表达式
{
Font oldFont;
Font newFont; // Get the font that is being used in the selected text
oldFont = this.richTextBoxText.SelectionFont; // If the font is using bold style now, we should remove the
// Formatting
if (oldFont.Bold)
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold); // Insert the new font and return focus to the RichTextBox
this.richTextBoxText.SelectionFont = newFont;
this.richTextBoxText.Focus();
}
//黑体与非黑体的转换,不太理解的是"oldFont.Style & ~FontStyle.Bold"和"oldFont.Style | FontStyle.Bold",为什么它们就能完成这个任务
Font (Font, FontStyle) 初始化新 Font,它使用指定的现有 Font 和 FontStyle 枚举。
Font (FontFamily, Single) 使用指定的大小初始化新 Font。
Font (String, Single) 使用指定的大小初始化新 Font。
然后在VS中看提示,上面代码中实际使用的又是(string,fload),我现在搞不清oldFont、oldFont.Style、FontStyle.Bold的实际数据类型是什么,在上面代码中的取值又是什么?弄清这个问题结贴了,呵呵
你说它实际用的是那个构造函数?
一元 & 运算符返回操作数的地址(要求 unsafe 上下文)。
为整型和 bool 类型预定义了二进制 & 运算符。对于整型,& 计算操作数的按位“与”。对于 bool 操作数,& 计算操作数的逻辑“与”;也就是说,当且仅当两个操作数均为 true 时,其结果才为 true。 ~ 运算符对操作数执行按位求补操作。为 int、uint、long 和 ulong 预定义了按位求补运算符
Ivony好有耐心,佩服~