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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:28:30+00:00 2026-05-29T05:28:30+00:00

I’ve already searched about this issue both on SO and other websites but I

  • 0

I’ve already searched about this issue both on SO and other websites but I haven’t managed to find (or come to) a solution for my case.

I have an abstract class called EnteBase, which I use as a base (duh!) for other two classes, Regione and Provincia.


EnteBase:

public abstract class EnteBase
{
    public EnteBase ()
        : this( "Sconosciuto", 0 )
    {
    }

    public EnteBase ( string nome )
        : this( nome, 0 )
    {
    }

    public EnteBase ( string nome, int numeroComuni )
    {
        this.Nome = nome;
        this.NumeroComuni = numeroComuni;
    }


    private string nome;
    public string Nome
    {
        [...]
    }

    private int numeroComuni;
    public int NumeroComuni
    {
        [...]
    }
}

Regione:

public class Regione : EnteBase
{
    public List<Provincia> Province
    {
        [...]
    }


    public Regione ()
        : base()
    {
        this.Province = new List<Provincia>();
    }

    public Regione ( string nome )
        : this()
    {
    }

    public Regione ( string nome, int numeroComuni )
        : this()
    {
    }


    public void AggiungiProvincia ( Provincia provincia )
    {
        Province.Add( provincia );
    }
}

Provincia:

public class Provincia : EnteBase
{
    private string sigla;

    public string Sigla
    {
        [...]
    }

    public Provincia ()
        : base()
    {
    }

    public Provincia ( string nome )
        : this()
    {
        this.Nome = nome;
    }

    public Provincia ( string nome, int numeroComuni )
        : this()
    {
        this.Nome = nome;
        this.NumeroComuni = numeroComuni;
    }

    public Provincia( string nome, int numeroComuni, string sigla)
        : this()
    {
        this.Nome = nome;
        this.NumeroComuni = numeroComuni;
        this.Sigla = sigla;
    }
}

My questions are the following:

  • Is it correct to use :this() in all constructors of the base class except the one with most parameters, with the others pointing towards the latter?
  • Is it correct to use :this() pointing to the base constructor in the classes Provincia and Regione and then assign to the fields from inside the method itself?

My problem rooted from the fact that I wanted to use both :this() and :base() in every method. When I discovered that it was not possible I looked for a solution, but I couldn’t find a way to apply what I saw in this question and this one.

P.S.: in constructors, is it preferred to use this.FieldName or just FieldName?

  • 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-29T05:28:31+00:00Added an answer on May 29, 2026 at 5:28 am

    Is it correct to use :this() in all constructors of the base class
    except the one with most parameters, with the others pointing towards
    the latter?

    The only use case is constructor chaining where you minimize your initialization work to one constructor and have all other constructor use this() with parameters that cause that constructor to execute – you are doing exactly this already in your EnteBase class.

    An empty base() call is generally useless, since the default base constructor is called by default anyway.

    An empty this() call is going the wrong way and generally useless too (unless you have some initialization work that does not depend on the parameters) – you should pass parameters a constructor with more parameters is called, eventually ending up at the one constructor that does all the work.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.