What is the difference between static, internal and public constructors? Why do we need to create all of them together?
static xyz()
{
}
public xyz()
{
}
internal xyz()
{
}
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.
The
staticconstructor will be called the first time an object of the type is instantiated or a static method is called. And will only run onceThe
publicconstructor is accessible to all other typesThe
internalconstructor is only accessible to types in the same assemblyOn top of these three there’s also
protectedwhich is only accessible to types derived from the enclosing typeand
protected internalwhich is only accessible to types in the same assembly or those that derives from the enclosing typeand
privatewhich is only accessible from the type itself and any nested types