Why use sealed instead of static on a class?
- by sq33G
Our system has several utility classes.
Some people on our team use (A) a class with all-static methods and a private constructor.
Others use (B) a class with all-static methods (these the juniors).
On code analysis, (A) and (B) raise warning CA1052, which recommends marking the class as sealed.
Included in the MSDN documentation there is the following advice:
If you are targeting .NET Framework 2.0 or earlier, a better approach is to mark the type as static.
Why does this make any sense? I would have thought the opposite; AFAIK, previous to 2.0 there was no way to mark a class as static.