Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:14+00:00 2026-05-28T14:46:14+00:00

Someone ask me that do we make an object of class having private constructor

  • 0

Someone ask me that do we make an object of class having private constructor

for E.g

    Class Parent
    {
        Private Parent()
        {
        }
    }

Since i made a private constructor for class Parent.so it is obvious that we can’t make object of Parent class.but is there is a way to make Parent class object without changing the private constructor into public?

Thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:46:15+00:00Added an answer on May 28, 2026 at 2:46 pm

    You can’t create an instance of Parent outside that class, but:

    • You can still create classes derived from Parent if they’re nested classes within Parent, and those could have non-private constructed.
    • Code (including static methods, most commonly) within the Parent type can create instances of Parent so you might have a static factory method, but not expose any constructors directly. For example:

      public class Parent
      {
          private Parent {}
      
          public static Parent CreateParent()
          {
              return new Parent();
          }
      }
      

    It can sometimes be useful to have this sort of approach, if you want to apply argument validation (etc) before creating an instance of a type, and you therefore want to force everything through named factory methods. That can also make code easier to read, particularly if you want to have different ways of creating an instance from the same number of values. TimeSpan.FromSeconds, TimeSpan.FromMinutes etc are good examples of this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do remember seeing someone ask something along these lines a while ago but
I want to ask how can someone read keystrokes while in a html page
I'm trying to make a ASP.NET (C#) poll that will ask a user a
Are there any known methods that can be used to make your software immune
I saw someone ask a question about detecting if a URL redirects from groovy
The location data is essentially in a tree structure. So when you ask someone
Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific
Someone told me about swamp diagrams explaning that they were useful to predict code
Someone told me that it's faster to concatenate strings with StringBuilder. I have changed
Sorry I can't be specific with code, but the problems I am seeing are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.