2014-04-14 34 views
0

我是一名VB開發人員,目前正在破譯用C#編寫的應用程序。通常我可以通過Google找到答案。但我迷失在此。什麼是在C#中使用的代字符(〜)?代字號(〜)在.NET中代表什麼?即currentStyle&=〜(int)(WindowStyles.WS_BORDER);

這裏是一個剪斷-它含有表達:

/// <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)); 
      } 
     } 

回答

5

這是bitwise NOT operator

在這種情況下,以下代碼:

currentStyle &= ~(int) (WindowStyles.WS_BORDER); 

可以解釋爲:鑄造WindowStyles.WS_BORDER枚舉到int,取逆位(使用~操作者),並與在currentStyle保存的值將它們合併使用&(按位與)。最後,將結果存儲回currentStyle變量。

+0

謝謝!我很欣賞這種迴應! – user1932634

相關問題