I have always wondered what this was about in a class where a public non-static method calls a private method.  Here is the example.

 public void CreateLocalResourceProvider(IContract contract)

        {

 

          …

          result = CreateDBProvider(String.Empty, contract);

          …

       }

 

private static IDBProvider CreateDBProvider(string a, IContract contract)

{

    …

 

}

 

After running enabling CodeAnalysis on my solution, I received a warning that the private method was not static  or that I needed to use the “this/me” keyword if appropriate.

 
Here is the help for this rule:
 
So now I understand why to use a static private method.  The things you learn from code
analysis.
 
Technorati Tags: , ,
Advertisements