Prevent usage of default constructor

  • If everything in the class is static, consider making it a static class. That way, you won't get a constructor at all.
  • If you want a parameterless constructor but you don't want it to be public, declare it explicitly and make it private (or internal etc)
  • If you don't want a parameterless constructor but do want constructors with parameters, then just declare the parameterized constructor - the default constructor won't be generated for you

I think that should cover all bases...


Make it private.

So,

class SomeClass
{
    private SomeClass()
    {
    }

    public SomeClass(int SomeParam)
    {
    }
}