CharacterRange.Equality(CharacterRange, CharacterRange) Operátor
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Porovná dva CharacterRange objekty. Získá hodnotu určující, zda First a Length hodnoty obou CharacterRange objektů jsou rovny.
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
Parametry
- cr1
- CharacterRange
A CharacterRange pro porovnání rovnosti.
- cr2
- CharacterRange
A CharacterRange pro porovnání rovnosti.
Návraty
true označující dva CharacterRange objekty mají stejné First hodnoty a Length hodnoty; falsev opačném případě .
Příklady
Následující příklad ukazuje použití operátoru Equality . Pokud chcete tento příklad spustit, vložte ho do formuláře Windows. Zpracujte událost formuláře Paint a volejte metodu CharacterRangeEquality1Paint z metody zpracování událostí a předejte e ji jako 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
Poznámky
Pomocí metody můžete také otestovat rovnost Equals .
Ekvivalentní metoda tohoto operátoru je CharacterRange.Equals(Object)