Color.Inequality(Color, Color) 演算子

定義

指定した 2 つの Color 構造体が異なるかどうかをテストします。

public:
 static bool operator !=(System::Drawing::Color left, System::Drawing::Color right);
public static bool operator != (System.Drawing.Color left, System.Drawing.Color right);
static member op_Inequality : System.Drawing.Color * System.Drawing.Color -> bool
Public Shared Operator != (left As Color, right As Color) As Boolean

パラメーター

left
Color

非等値演算子の左側に表示される Color

right
Color

非等値演算子の右側に表示される Color

戻り値

2 つの Color 構造体が異なる場合は true。それ以外の場合は false

次のコード例では、 Inequality 演算子と クラスを SystemColors 示します。 この例は、 という名前 Button2のボタンを含む Windows フォームで使用するように設計されています。 次のコードをフォームに貼り付け、メソッドを Button2_Click ボタンの Click イベントに関連付けます。

void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( this->BackColor != SystemColors::ControlDark )
   {
      this->BackColor = SystemColors::ControlDark;
   }

   if (  !(this->Font->Bold) )
   {
      this->Font = gcnew System::Drawing::Font( this->Font,FontStyle::Bold );
   }
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{

    if (this.BackColor != SystemColors.ControlDark)
    {
        this.BackColor = SystemColors.ControlDark;
    }
    if (!(this.Font.Bold))
    {
        this.Font = new Font(this.Font, FontStyle.Bold);
    }
}
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    If (Color.op_Inequality(Me.BackColor, SystemColors.ControlDark)) Then
        Me.BackColor = SystemColors.ControlDark
    End If
    If Not (Me.Font.Bold) Then
        Me.Font = New Font(Me.Font, FontStyle.Bold)
    End If
End Sub

注釈

このメソッドは、構造体の ARGB 値よりも多くを Color 比較します。 また、一部の状態フラグの比較も行います。 2 つの Color 構造体の ARGB 値のみを比較する場合は、 メソッドを使用します ToArgb

適用対象