views:

474

answers:

2

Possible Duplicate:
When to Use Static Classes in C#

Questions in the title..........i would greatly appreciate opinions on when it's best to use each?

Regards

A: 

That's the case when you don't have access to that different class (see Jon Skeet's answer). However, when you do have access to the code then the rule I use is the following:

Can I get away with using a static class, or do I need to store different data in that class each time?

Hope this helps.

EDIT: Disregard the first sentence since Jon Skeet deleted his answer.

tzup
A: 

I use static classes when they just contain fairly simple helper methods. In other cases I use instances of objects, so that I can do dependency injection and write proper unit tests.

Grzenio