Font.Equals(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示指定的对象是否为 Font,并且具有与此 Font相同的 FontFamily、GdiVerticalFont、GdiCharSet、Style、Size和 Unit 属性值。
public:
override bool Equals(System::Object ^ obj);
public override bool Equals (object? obj);
public override bool Equals (object obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean
参数
- obj
- Object
要测试的对象。
返回
如果 obj
参数是 Font 且具有与此 Font相同的 FontFamily、GdiVerticalFont、GdiCharSet、Style、Size和 Unit 属性值,则 true
;否则,false
。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码创建两个 Font 对象,然后测试它们是否等效。
public:
void Equals_Example( PaintEventArgs^ /*e*/ )
{
// Create a Font object.
System::Drawing::Font^ firstFont = gcnew System::Drawing::Font( "Arial",16 );
// Create a second Font object.
System::Drawing::Font^ secondFont = gcnew System::Drawing::Font( gcnew FontFamily( "Arial" ),16 );
// Test to see if firstFont is identical to secondFont.
bool fontTest = firstFont->Equals( secondFont );
// Display a message box with the result of the test.
MessageBox::Show( fontTest.ToString() );
}
public void Equals_Example(PaintEventArgs e)
{
// Create a Font object.
Font firstFont = new Font("Arial", 16);
// Create a second Font object.
Font secondFont = new Font(new FontFamily("Arial"), 16);
// Test to see if firstFont is identical to secondFont.
bool fontTest = firstFont.Equals(secondFont);
// Display a message box with the result of the test.
MessageBox.Show(fontTest.ToString());
}
Public Sub Equals_Example(ByVal e As PaintEventArgs)
' Create a Font object.
Dim firstFont As New Font("Arial", 16)
' Create a second Font object.
Dim secondFont As New Font(New FontFamily("Arial"), 16)
' Test to see if firstFont is identical to secondFont.
Dim fontTest As Boolean = firstFont.Equals(secondFont)
' Display a message box with the result of the test.
MessageBox.Show(fontTest.ToString())
End Sub