Use String.Compare
In This Article
Replaces the equality expression with a call to String.Compare.
#Availability
Available from the context menu or via shortcuts:
- when a Boolean expression that compares strings, using either the equality or inequality operator is selected.
#Example
private string testString = "My text";
private bool TestMethod(string param1)
{
return │param1 == testString;
}
Private testString As String = "My text"
Private Function TestMethod(ByVal param1 As String) As String
Return │param1 = testString
End Function
Result:
private string testString = "My text";
private bool TestMethod(string param1)
{
return │String.Compare(param1, testString, false) == 0;
}
Private testString As String = "My text"
Private Function TestMethod(ByVal param1 As String) As String
Return │String.Compare(param1, testString, False) = 0
End Function