CharacterRange.Inequality(CharacterRange, CharacterRange) 運算子
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
比較兩個 CharacterRange 物件。 獲得一個值,表示兩個First物件的 or 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
A CharacterRange 用於比較不平等。
- cr2
- CharacterRange
A CharacterRange 用於比較不平等。
傳回
true 表示 FirstLength 或 兩個物件的值 CharacterRange 不同;否則, false。
範例
以下範例示範如何使用此 Inequality 方法。 要執行這個範例,請將它貼到 Windows 表單中。 處理表單的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)