Font.GetHashCode 方法

定义

获取此 Font 的哈希代码。

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

返回

Font 的哈希代码。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 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

适用于