How to Add Custom Rule to FXCop for avoiding == operator inside the method

Posted by Jameel on Stack Overflow See other posts from Stack Overflow or by Jameel
Published on 2012-11-02T10:30:50Z Indexed on 2012/11/02 11:00 UTC
Read the original article Hit count: 321

Filed under:
|

I want to add a Custom rule for avoiding the '==' operator inside a method in a class. For example in the below method i need to avoid 'str1==str2' with string.Compare(str1, str2,StringComparison.Ordinal);.So I need to check this types of code are appear in any of the method

public void StringTest2()
    {
        string str1 = "Hello";
        string str2 = "HELLO";
        if (str1 == str2)
        {
        }
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about fxcop