Skip to content

Commit 6e24cbf

Browse files
authored
Compare CompareTo return with zero in examples (dotnet#5160)
1 parent eeddcd2 commit 6e24cbf

File tree

3 files changed

+7
-7
lines changed
  • samples/snippets
    • cpp/VS_Snippets_CLR/IComparable`1 Example/CPP
    • csharp/VS_Snippets_CLR/IComparable`1 Example/CS
    • visualbasic/VS_Snippets_CLR/IComparable`1 Example/VB

3 files changed

+7
-7
lines changed

samples/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public ref class Temperature: public IComparable<Temperature^> {
2727
// Define the is greater than operator.
2828
bool operator>= (Temperature^ other)
2929
{
30-
return CompareTo(other) == 1;
30+
return CompareTo(other) >= 0;
3131
}
3232

3333
// Define the is less than operator.
3434
bool operator< (Temperature^ other)
3535
{
36-
return CompareTo(other) == -1;
36+
return CompareTo(other) < 0;
3737
}
3838

3939
// Define the is greater than or equal to operator.
4040
bool operator> (Temperature^ other)
4141
{
42-
return CompareTo(other) >= 0;
42+
return CompareTo(other) > 0;
4343
}
4444

4545
// Define the is less than or equal to operator.

samples/snippets/csharp/VS_Snippets_CLR/IComparable`1 Example/CS/source.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public int CompareTo(Temperature other)
2020
// Define the is greater than operator.
2121
public static bool operator > (Temperature operand1, Temperature operand2)
2222
{
23-
return operand1.CompareTo(operand2) == 1;
23+
return operand1.CompareTo(operand2) > 0;
2424
}
2525

2626
// Define the is less than operator.
2727
public static bool operator < (Temperature operand1, Temperature operand2)
2828
{
29-
return operand1.CompareTo(operand2) == -1;
29+
return operand1.CompareTo(operand2) < 0;
3030
}
3131

3232
// Define the is greater than or equal to operator.

samples/snippets/visualbasic/VS_Snippets_CLR/IComparable`1 Example/VB/source.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Public Class Temperature
2020

2121
' Define the is greater than operator.
2222
Public Shared Operator > (operand1 As Temperature, operand2 As Temperature) As Boolean
23-
Return operand1.CompareTo(operand2) = 1
23+
Return operand1.CompareTo(operand2) > 0
2424
End Operator
2525

2626
' Define the is less than operator.
2727
Public Shared Operator < (operand1 As Temperature, operand2 As Temperature) As Boolean
28-
Return operand1.CompareTo(operand2) = -1
28+
Return operand1.CompareTo(operand2) < 0
2929
End Operator
3030

3131
' Define the is greater than or equal to operator.

0 commit comments

Comments
 (0)