I am bit confused in the usage of Static class, Private constructor and abstract class
to prevent instance creation.( Confused about the alternatives).
What is the scenario that fit the best for each ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That depends on your needs.
Static class may be considered “a bunch of methods” – you would use it, if you just need to group some methods, sample usage: MathHelpers, with methods like Sin, Cos, ConvertXToY (or to host extension methods).
Private constructor – this one you would use, when you want to be able to control how the object is created, for example, if you want to make sure, that those objects can only be created by your static methods. An example: