tags:

views:

132

answers:

2

Duplicate

http://stackoverflow.com/questions/731763/should-c-methods-that-can-be-static-be-static


Other then the obvious downsides of inheritance and variable scope, if you have a method that is completely contained should you always declare it as static? Are there any downside to declaring methods as static? Especially in terms of garbage collection.

A: 

Here's a great post on the topic..

http://stackoverflow.com/questions/731763/should-c-methods-that-can-be-static-be-static

madcolor
+2  A: 

It's irrelevant to garbage collection.

If the method is non-virtual and doesn't use any instance variables, I'd make it static. That makes it clear that it isn't related to a particular instance.

Jon Skeet