Skip to content

Primary Constructors aren't consistent with regular constructors #76973

Closed as not planned
@Statharas

Description

@Statharas

Version Used: 9.0

Steps to Reproduce:

https://sharplab.io/#gist:6e196059c74644a3962eb9b9ba08aabf

In the above snippet (albeit a bad practice) is an example of using the primary ctor that will introduce an inconsistency due to the ordering of the constructors.

As per the following explanation, this effectively doesn't share the same behavior as a regular ctor.

Image

Given the above, the following example shows exactly why this happens:

Image

Image

Image

Expected Behavior:

It is expected that a primary constructor would be able to replace a regular constructor

Actual Behavior:
The primary constructor does not have the same behavior as the regular constructor

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions