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

  • Home
  • SEARCH
  • 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 7553037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:56:24+00:00 2026-05-30T10:56:24+00:00

I am new to CSharp.I have seen this() in some code.My question is Suppose

  • 0

I am new to CSharp.I have seen “this()” in some code.My question is Suppose if i call

Paremeterized constructor ,am i invoking the paremeterless constructor forcefully?.But According to constructor construction ,i believe parameterless constructor will be executed first.Can you please explain this with simple example so that i can get exactly when should i call “this()”.Thanks in advance.

 public OrderHeader() { }

 public OrderHeader(string Number, DateTime OrderDate, int ItemQty)
            : this()
        {

          // Initialization goes here ....
        }
  • 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-30T10:56:25+00:00Added an answer on May 30, 2026 at 10:56 am

    By default (for classes), there is an implicit :base(), so it is always chaining something. Adding :this() calls the parameterless constructor of the current type, and so on – sooner or later it will call down to a base constructor of some kind. Yes, the :this(…) or :base(…) happens before the constructor body.

    In the example shown, adding :this() does no harm, but does nothing useful either. In more complex scenarios, :this(…) is commonly used to avoid duplicating constructor code – usually directing all constructors to the most parameterized version – for example:

    public Foo() : this(27, "abc") {} // default values
    public Foo(int x, string y) {...validation, assignment, etc...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have code in csharp that returns this string: {'dateTimeFormat': 'iso8601', 'wikiURL': http://simile.mit.edu/shelf/ ,
i have code that takes a csharp datetime and converts it into a long
I have implemented my Server application regarding this post here: http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c8781#Client1 Sum up: I
Here is the reason why this question was being asked: www.devplusplus.com/Tests/CSharp/Hello_World . While similar
I am learnig CSharp.I have some doubts in handling exceptions.Kindly guide me to improve
I have the following, fairly standard code as a wrapper around CSharpCodeProvider . This
I recently asked this question , but after some of the responses and some
New to javascript/jquery and having a hard time with using this or $(this) to
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {

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.