`this()` is not necessary since C#11
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- csharp
- Domain
- documentation
Research direction
The example is in docs/csharp/modern-events.md, in the SearchDirectoryArgs struct, where the constructor ends with : this(). Remove that initializer and check the prose just above or below it, which says this() is needed to avoid the unassigned-property error; that sentence needs rewording or removal too. Done when the example compiles as written under C# 11 and the explanation matches it.
Written by the indexing model from the issue text.
Description
Type of issue
Typo
Description
The code example of struct SearchDirectoryArgs has an example constructor internal SearchDirectoryArgs(string dir, int totalDirs, int completedDirs) : this() . The text explains that calling this() because Without that addition, the rules of C# would report that the properties are being accessed before being assigned..
The reason is not true since C#11. The compiler automatically zero-initializes any fields you don't assign in a constructor. I suggest we remove this() because all 3 properties are initialized and this is a beginner-friendly document:)
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/modern-events
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/modern-events.md
Document Version Independent Id
645a8a12-a026-bee9-7501-e8ec4a32ce31
Platform Id
9c865adf-6af0-1f7e-0fcb-510d233d5680
Article author
@BillWagner
Metadata
- ID: 2cb74e28-b327-0f9f-5fa5-882a00d10ceb
- PlatformId: 9c865adf-6af0-1f7e-0fcb-510d233d5680
- Service: dotnet-csharp
- Sub-service: fundamentals
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 14h 12m
- Merged PRs (30d)
- 312
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/docs
-
dotnet-fundamentals/svc install/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Upgrade from `net9.0` to LTS (or STS) image tagPossibly taken @ShyneChikwapulo claimed this 5 days ago. Opendotnet-target-version
Difficulty 1/5 Under an hour Newbie friendliness 85/100
dotnet/docs#56293 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
dotnet-fundamentals/svc
Difficulty 1/5 Under an hour Newbie friendliness 92/100
dotnet/docs#56289 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Add more to the documentationPossibly taken @adarsh6980 claimed this 20 days ago. Opendotnet-fsharp/svc help wanted
Difficulty 1/5 Under an hour Newbie friendliness 90/100
dotnet/docs#56209 · 2 comments ·
Maintainers usually reply within 1 day
-
:watch: Not Triaged
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
Similar issues
-
documentation v0.9.2
Difficulty 2/5 Half a day Newbie friendliness 72/100
khuisman/mcp-gee-sweet#1033 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 2 days
-
docs hacktoberfest help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
pacocartones/free-llm-api-hub#347 ·
Maintainers usually reply within 1 day
-
customer-reported question
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Azure/azure-sdk-for-python#49548 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
The-Swarm-Corporation/swarms-framework-docs#302 ·
Maintainers usually reply within 1 day