ReSharper complains when method can be static, but isn't

Andreas Grech picture Andreas Grech · Apr 26, 2009 · Viewed 8.8k times · Source

Why does ReSharper complain when a method can become static, but is not?

Is it because only one instance of a static method is created (on the type) and thus save on performance?

Answer

Brian Rasmussen picture Brian Rasmussen · Apr 26, 2009

I find that comment very useful as it points out two important things:

  1. It makes me ask myself if the method in question should actually be part of the type or not. Since it doesn't use any instance data, you should at least consider if it could be moved to its own type. Is it an integral part of the type, or is it really a general purpose utility method?

  2. If it does make sense to keep the method on the specific type, there's a potential performance gain as the compiler will emit different code for a static method.