CharacterRange.Inequality(CharacterRange, CharacterRange) 運算子
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
比較兩個 CharacterRange 物件。 取得值,指出兩個 First 物件的 Length 或 CharacterRange 值是否不相等。
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 op_Inequality : System.Drawing.CharacterRange * System.Drawing.CharacterRange -> bool
Public Shared Operator != (cr1 As CharacterRange, cr2 As CharacterRange) As Boolean
參數
- cr1
- CharacterRange
要比較是否不相等的 CharacterRange。
- cr2
- CharacterRange
要比較是否不相等的 CharacterRange。
傳回
true
表示兩個 First 物件的 Length 或 CharacterRange 值不同,否則為 false
。
範例
下列範例示範如何使用 Inequality 方法。 若要執行此範例,請將它貼到 Windows Form 中。 處理表單的事件 Paint ,並從事件處理方法呼叫 CharacterRangeInequality
方法 Paint ,並傳遞 e
為 PaintEventArgs。
private void CharacterRangeInequality()
{
// 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("string"), "strings".Length);
if (range1 != range2)
MessageBox.Show("The ranges are not equal.");
else
MessageBox.Show("The ranges are equal.");
}
Private Sub CharacterRangeInequality()
' 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("string"), "strings".Length)
If range1 <> range2 Then
MessageBox.Show("The ranges are not equal.")
Else
MessageBox.Show("The ranges are equal.")
End If
End Sub
備註
方法 Inequality 會傳回 方法的 Equality 相反。
這個運算子的對等方法為 CharacterRange.Equals(Object)