FontFamily.Equals(Object) 方法
定义
指示指定的对象是否为 FontFamily 以及是否与此 FontFamily 相等。Indicates whether the specified object is a FontFamily and is identical to this FontFamily.
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
要测试的对象。The object to test.
返回
如果 obj 为 FontFamily 且与此 FontFamily 相等,则为 true;否则为 false。true if obj is a FontFamily and is identical to this FontFamily; otherwise, false.
示例
下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:
测试它们是否等效。Tests whether they are equivalent.
在消息框中显示测试结果。Displays the result of the test in a message box.
public:
void Equals_Example( PaintEventArgs^ /*e*/ )
{
// Create two FontFamily objects.
FontFamily^ firstFontFamily = gcnew FontFamily( "Arial" );
FontFamily^ secondFontFamily = gcnew FontFamily( "Times New Roman" );
// Check to see if the two font families are equivalent.
bool equalFonts = firstFontFamily->Equals( secondFontFamily );
// Display the result of the test in a message box.
MessageBox::Show( equalFonts.ToString() );
}
public void Equals_Example(PaintEventArgs e)
{
// Create two FontFamily objects.
FontFamily firstFontFamily = new FontFamily("Arial");
FontFamily secondFontFamily = new FontFamily("Times New Roman");
// Check to see if the two font families are equivalent.
bool equalFonts = firstFontFamily.Equals(secondFontFamily);
// Display the result of the test in a message box.
MessageBox.Show(equalFonts.ToString());
}
Public Sub Equals_Example(ByVal e As PaintEventArgs)
' Create two FontFamily objects.
Dim firstFontFamily As New FontFamily("Arial")
Dim secondFontFamily As New FontFamily("Times New Roman")
' Check to see if the two font families are equivalent.
Dim equalFonts As Boolean = _
firstFontFamily.Equals(secondFontFamily)
' Display the result of the test in a message box.
MessageBox.Show(equalFonts.ToString())
End Sub