Monthly Archives: April 2012

Why need Static methods?

I use static methods when I need to get something that is relevant to that class but I don’t want to create an instance every time to get this information. With a static method you cannot access methods/properties/variables from the class. The only variables available are within the static method you are calling.

Typically Helper and Utility methods are good candidates. Often times as well, you may want to create Static as well as instance objects. Looking to the framework, there’s the File and the FileInfo, the Directory and directoryInfo. Similarly, check out the Data Access Application Block – all of the SqlHelper methods are static.

Advertisements

Leave a comment

Filed under C#