Sealed vs. Private constructor

  • Thread starter Thread starter wiredless
  • Start date Start date
W

wiredless

Hi,

To minimize resource usage on a WinCE app I want to seal classes and methods
that do not get inherited. Is it still good practice to set the class
constructor to private or is it covered by using sealed?
 
They're used for difference scenarios. One prevents object creation, one
prevents inheritance. If you don't want the ctor visible, make it private,
regardless of whether you want to seal the class or not. If you don't want
it to be inheritable, then seal it. The scope of the ctor has no relevence
on it.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top