C# 波浪号(~)在.NET中代表什么?i、 e currentStyle&;=~(int)(WindowStyles.WS_边框);
我是一名VB开发人员,目前正在破解一个用C#编写的应用程序。一般来说,我可以通过谷歌找到答案。但我对这件事迷茫了。C#中的波浪线(~)是用来做什么的 下面是一个包含以下表达式的剪报:C# 波浪号(~)在.NET中代表什么?i、 e currentStyle&;=~(int)(WindowStyles.WS_边框);,c#,.net,C#,.net,我是一名VB开发人员,目前正在破解一个用C#编写的应用程序。一般来说,我可以通过谷歌找到答案。但我对这件事迷茫了。C#中的波浪线(~)是用来做什么的 下面是一个包含以下表达式的剪报: /// <summary> /// Updates the window style for the parent form. /// </summary> private void UpdateStyle() {
/// <summary>
/// Updates the window style for the parent form.
/// </summary>
private void UpdateStyle()
{
// remove the border style
Int32 currentStyle = Win32Api.GetWindowLong(Handle, GWLIndex.GWL_STYLE);
if ((currentStyle & (int)(WindowStyles.WS_BORDER)) != 0)
{
currentStyle &= ~(int) (WindowStyles.WS_BORDER);
Win32Api.SetWindowLong(_parentForm.Handle, GWLIndex.GWL_STYLE, currentStyle);
Win32Api.SetWindowPos(_parentForm.Handle, (IntPtr) 0, -1, -1, -1, -1,
(int) (SWPFlags.SWP_NOZORDER | SWPFlags.SWP_NOSIZE | SWPFlags.SWP_NOMOVE |
SWPFlags.SWP_FRAMECHANGED | SWPFlags.SWP_NOREDRAW | SWPFlags.SWP_NOACTIVATE));
}
}
//
///更新父窗体的窗口样式。
///
私有void UpdateStyle()
{
//删除边框样式
Int32 currentStyle=Win32Api.GetWindowLong(句柄,GWLIndex.GWL_样式);
如果((currentStyle&(int)(WindowStyles.WS_BORDER))!=0)
{
currentStyle&=~(int)(WindowStyles.WS_边框);
Win32Api.SetWindowLong(_parentForm.Handle,GWLIndex.GWL_样式,currentStyle);
Win32Api.SetWindowPos(_parentForm.Handle,(IntPtr)0,-1,-1,-1,
(int)(SWPFlags.SWP_NOZORDER | SWPFlags.SWP_NOSIZE | SWPFlags.SWP_NOMOVE)|
SWPFlags.SWP_FRAMECHANGED | SWPFlags.SWP_NOREDRAW | SWPFlags.SWP_NOACTIVATE |);
}
}
这是最重要的
在这种情况下,使用以下代码:
currentStyle &= ~(int) (WindowStyles.WS_BORDER);
可以解释为:将WindowStyles.WS_BORDER
枚举强制转换为int
,取逆位(使用~
运算符),并使用&
将它们与当前样式
中保存的值合并(按位和)。最后,将结果存储回currentStyle
变量。它是最重要的
在这种情况下,使用以下代码:
currentStyle &= ~(int) (WindowStyles.WS_BORDER);
可以解释为:将
WindowStyles.WS_BORDER
枚举强制转换为int
,取逆位(使用~
运算符),并使用&
将它们与当前样式
中保存的值合并(按位和)。最后,将结果存储回currentStyle
变量。谢谢!感谢您的回复!!非常感谢。感谢您的回复!!