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 7832619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:19:10+00:00 2026-06-02T12:19:10+00:00

I study C# and I’m trying to understand the overloaded constructor, how it works

  • 0

I study C# and I’m trying to understand the overloaded constructor, how it works and the point using them like a chain call? Why just not have only one constructor with all necessary parameters? Below I have some helping code for a task I’m working with, and I need some help to understand the point with all this constructors. Preciate some help! Thanks!

    public class Email
{
    //private email
    private string m_personal;
    //work mail
    private string m_work;

    public Email()
    {
    }

    public Email(string workMail) : this(workMail, string.Empty)
    {
    }

    public Email(string workMail, string personalMail)
    {
        m_work = workMail;
        m_personal = personalMail;
    }

    public string Personal
    {
        //private mail
        get { return m_personal; }

        set { m_personal = value; }
    }

    public string Work
    {
        get { return m_work; }

        set { m_work = value; }
    }

    public string GetToStringItemsHeadings
    {
        get { return string.Format("{0,-20} {1, -20}", "Office Email", "Private Email"); }
    }

    public override string ToString()
    {
        string strOut = string.Format("{0,-20} {1, -20}", m_work, m_personal);
        return strOut;
    }


}
  • 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-06-02T12:19:15+00:00Added an answer on June 2, 2026 at 12:19 pm

    Why just not have only one constructor with all necessary parameters?

    What if users of your class are only interested in some parameters? Using your example, what if somebody doesn’t have personal email? Should they pass null or string.Empty? This kind of type-level knowledge is best handled by type itself.

    By exposing extra constructor with work email only, you’re essentially telling your class consumers “Don’t have personal email? Don’t worry, I will handle it”.

    On top of that, chaining definitions naturally helps to avoid code redundancy.

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

Sidebar

Related Questions

I am trying to study how the REST service approach works using Jersey. I
I just begin to study ARM assembly language, and am not clear about how
I am trying to study C, and I am running in to troubles using
i start to study asp.Net now, i understand basic html (css not) i need
I just started to study the Model View Controller pattern. I now understand the
As a case study, I am trying to get to grips with this code
I like to study languages outside my comfort zone, but I've had a hard
I am trying to study some aspects of ddd with the domain of a
I'm study about NSNotificationCenter. Here is my code Observer.m //note init method is not
I'm doing a study on large Java projects and would like to view the

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.