CharacterRange.Equality(CharacterRange, CharacterRange) 연산자

정의

CharacterRange 개체를 비교합니다.Compares two CharacterRange objects. First 개체의 LengthCharacterRange 값이 같은지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the First and Length values of the two CharacterRange objects are equal.

public:
 static bool operator ==(System::Drawing::CharacterRange cr1, System::Drawing::CharacterRange cr2);
public static bool operator == (System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2);
static member ( = ) : System.Drawing.CharacterRange * System.Drawing.CharacterRange -> bool
Public Shared Operator == (cr1 As CharacterRange, cr2 As CharacterRange) As Boolean

매개 변수

cr1
CharacterRange

일치 여부를 비교할 CharacterRange입니다.A CharacterRange to compare for equality.

cr2
CharacterRange

일치 여부를 비교할 CharacterRange입니다.A CharacterRange to compare for equality.

반환

true 개체의 CharacterRangeFirst 값이 같으면 Length이고 그렇지 않으면 false입니다.true to indicate the two CharacterRange objects have the same First and Length values; otherwise, false.

예제

다음 예제에서는 Equality 연산자를 사용 하는 방법을 보여 줍니다.The following example demonstrates how to use the Equality operator. 이 예제를 실행 하려면 Windows 폼에 붙여 넣습니다.To run this example, paste it into a Windows Form. 양식의 처리 Paint 이벤트 및 호출 합니다 CharacterRangeEquality1 메서드에서 Paint 전달 하는 이벤트 처리 메서드를 e 으로 PaintEventArgs입니다.Handle the form's Paint event and call the CharacterRangeEquality1 method from the Paint event-handling method, passing e as PaintEventArgs.

private void CharacterRangeEquality1()
{

    // Declare the string to draw.
    string message = "Strings or strings; that is the question.";

    // Compare the ranges for equality. The should not be equal.
    CharacterRange range1 = 
        new CharacterRange(message.IndexOf("Strings"), "Strings".Length);
    CharacterRange range2 = 
        new CharacterRange(message.IndexOf("strings"), "strings".Length);

    if (range1 == range2)
        MessageBox.Show("The ranges are equal.");
    else
        MessageBox.Show("The ranges are not equal.");
}
Private Sub CharacterRangeEquality1() 
    
    ' Declare the string to draw.
    Dim message As String = "Strings or strings; that is the question."
    
    ' Compare the ranges for equality. The should not be equal.
    Dim range1 As New CharacterRange(message.IndexOf("Strings"), _
        "Strings".Length)
    Dim range2 As New CharacterRange(message.IndexOf("strings"), _
        "strings".Length)
    
    If range1 = range2 Then
        MessageBox.Show("The ranges are equal.")
    Else
        MessageBox.Show("The ranges are not equal.")
    End If
 
End Sub

설명

Equals 메서드를 사용 하 여 같은지 여부를 테스트할 수도 있습니다.You can also test for equality using the Equals method.

이 연산자에 대 한 해당 메서드는 CharacterRange.Equals(Object)The equivalent method for this operator is CharacterRange.Equals(Object)

적용 대상