Skip to content

"A constructor that takes no parameters is called a default constructor." #10517

Closed

Description

@tjcrowder

The linked page says:

A constructor that takes no parameters is called a default constructor.

That's incorrect (and the page misuses this term throughout). It's called a parameterless (or no-parameters, or zero-parameters) constructor. As it says in the specification (§15.11.5), a default constructor is the constructor the C# compiler provides for you if you don't specify any constructors in your code. The default constructor is a parameterless constructor, but not all parameterless constructors are default constructors. If the constructor is explicitly written in the class, by definition it's not a default constructor.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

  1. ASKemp commented on Feb 18, 2019

    @ASKemp

    I'm getting (an issue?) that unless I provide a parameterless constructor then I can't declare a constructor with a parameter, at least, it'll give an error when run of no matching property. I.e. if you want to use a constructor with a parameter then you must also declare a parameterless constructor.

  2. added this to the milestone on Feb 25, 2019
  3. BillWagner commented on Feb 25, 2019

    @BillWagner
    Member

    Thanks for raising this issue. You are correct @tjcrowder

    @ASKemp For your issue, I'd need to see a small sample to understand what's the core reason.

  4. modified the milestones: , March 2019 on Mar 11, 2019
  5. self-assigned this
    on Apr 3, 2019
  6. added a commit that references this issue on Apr 19, 2019
    b2d73e8
  7. added a commit that references this issue on Apr 20, 2019
    1828bf9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions