Font.GetHashCode 方法

定義

取得這個 Font 的雜湊碼。

public:
 override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer

傳回

這個 Font 的雜湊程式碼。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 建立 Font

  • 取得該字型的哈希碼。

  • 顯示具有哈希碼值的消息框。

public:
   void GetHashCode_Example( PaintEventArgs^ /*e*/ )
   {
      // Create a Font object.
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );

      // Get the hash code for myFont.
      int hashCode = myFont->GetHashCode();

      // Display the hash code in a message box.
      MessageBox::Show( hashCode.ToString() );
   }
public void GetHashCode_Example(PaintEventArgs e)
{
             
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    // Get the hash code for myFont.
    int hashCode = myFont.GetHashCode();
             
    // Display the hash code in a message box.
    MessageBox.Show(hashCode.ToString());
}
Public Sub GetHashCode_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim myFont As New Font("Arial", 16)

    ' Get the hash code for myFont.
    Dim hashCode As Integer = myFont.GetHashCode()

    ' Display the hash code in a message box.
    MessageBox.Show(hashCode.ToString())
End Sub

適用於