FontFamily.GetHashCode 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得這個 FontFamily的哈希碼。
public:
override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer
傳回
這個 FontFamily的哈希碼。
範例
下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse
,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:
建立 FontFamily。
取得字型系列的哈希碼。
將哈希碼的值繪製到畫面做為文字。
public:
void GetHashCode_Example( PaintEventArgs^ e )
{
// Create a FontFamily object.
FontFamily^ myFontFamily = gcnew FontFamily( "Arial" );
// Get the hash code for myFontFamily.
int hashCode = myFontFamily->GetHashCode();
// Draw the value of hashCode to the screen as a string.
e->Graphics->DrawString( String::Format( "hashCode = {0}", hashCode ),
gcnew System::Drawing::Font( myFontFamily,16 ), Brushes::Black, PointF(0,0) );
}
public void GetHashCode_Example(PaintEventArgs e)
{
// Create a FontFamily object.
FontFamily myFontFamily = new FontFamily("Arial");
// Get the hash code for myFontFamily.
int hashCode = myFontFamily.GetHashCode();
// Draw the value of hashCode to the screen as a string.
e.Graphics.DrawString(
"hashCode = " + hashCode.ToString(),
new Font(myFontFamily, 16),
Brushes.Black,
new PointF(0, 0));
}
Public Sub GetHashCode_Example(ByVal e As PaintEventArgs)
' Create a FontFamily object.
Dim myFontFamily As New FontFamily("Arial")
' Get the hash code for myFontFamily.
Dim hashCode As Integer = myFontFamily.GetHashCode()
' Draw the value of hashCode to the screen as a string.
e.Graphics.DrawString("hashCode = " & hashCode.ToString(), _
New Font(myFontFamily, 16), Brushes.Black, New PointF(0, 0))
End Sub