Font.Equals(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示指定对象是否为 Font,以及是否具有与此 FontFamily 相同的 GdiVerticalFont、GdiCharSet、Style、Size、Unit 和 Font 属性值。
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
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈