Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify to code initializer rather than ctor #41748

Open
DickBaker opened this issue Jul 13, 2024 · 2 comments
Open

simplify to code initializer rather than ctor #41748

DickBaker opened this issue Jul 13, 2024 · 2 comments
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri3

Comments

@DickBaker
Copy link
Contributor

Type of issue

Outdated article

Description

imho the first "public class Taxi" example should be simplified. The existing sample

public class Taxi
{
    public bool IsInitialized;

    public Taxi()
    {
        IsInitialized = true;
    }
}

could be

public class Taxi
{
    public bool IsInitialized = true;
}

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/using-constructors

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/using-constructors.md

Document Version Independent Id

36d0bf3a-29bf-5162-c700-142b03f9a16c

Article author

@BillWagner

Metadata

  • ID: 374a58d4-1905-c664-04b6-fd68e617f8c9
  • Service: dotnet-csharp
  • Sub-service: fundamentals
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 13, 2024
@issues-automation issues-automation bot added dotnet-csharp/svc fundamentals/subsvc Pri1 High priority, do before Pri2 and Pri3 labels Jul 13, 2024
@BillWagner BillWagner added Pri2 Pri3 doc-enhancement Improve the current content [org][type][category] and removed Pri1 High priority, do before Pri2 and Pri3 Pri2 labels Jul 15, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Jul 15, 2024
@BillWagner
Copy link
Member

There's a number of updates that could be made in the area of constructors. Everything from field initializers to init only properties to required properties and so on.

I agree that this example isn't a great one. Code like this should use an initializer instead. It should be part of a suite of examples that show the different techniques, and some guidance about determining which fits different design goals best.

@DickBaker
Copy link
Contributor Author

yup this is doubtless one of MANY, but suggest we [MS+Community] try to improve the doc experience whenever we can and not get daunted by the enormity of the beast, so I hope you might accept this minor contrib.
Sometimes I get riled by something that results in a major work (Issue #10110, PR #10113) but hope these all contribute positive improvement to the doc real-estate. I hope that you welcome such assistance anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri3
Projects
None yet
Development

No branches or pull requests

3 participants