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

The code example for foreach does not work #40755

Closed
MarekDomas opened this issue May 4, 2024 · 3 comments · Fixed by #40792
Closed

The code example for foreach does not work #40755

MarekDomas opened this issue May 4, 2024 · 3 comments · Fixed by #40792
Assignees
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc lang-reference/subsvc okr-health Content-health KR: Concerns article defects/freshness or build warnings. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@MarekDomas
Copy link

MarekDomas commented May 4, 2024

Type of issue

Code doesn't work

Description

[Enter feedback here]
The Code example of foreach statement with list of fibonaci numbers does not work.
The list need to be initialized differently :
Instead of: List<int> fibNumbers = [0, 1, 1, 2, 3, 5, 8, 13];
It should be: List<int> fibNumbers = new List<int> {0, 1, 1, 2, 3, 5, 8, 13};

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements#code-try-6

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/statements/iteration-statements.md

Document Version Independent Id

8b6cb66c-8bef-fed0-1677-acee6bd3e052

Article author

@BillWagner

Metadata

  • ID: 23685290-d092-48ee-f7d9-e2c2bdc86a18
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Associated WorkItem - 252999

@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 4, 2024
@issues-automation issues-automation bot added dotnet-csharp/svc lang-reference/subsvc Pri1 High priority, do before Pri2 and Pri3 labels May 4, 2024
@BillWagner
Copy link
Member

Hi @MarekDomas

The code is correct. It's using the new C# 12 feature collection expressions.

I'll close this as by design.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged and removed ⌚ Not Triaged Not triaged labels May 7, 2024
@MarekDomas
Copy link
Author

Yes, i know about this feature, but the built in code editor, does not compile the code.

@BillWagner
Copy link
Member

Reopening this one. We should disable collection expressions here until Try.NET gets updated.

@BillWagner BillWagner reopened this May 7, 2024
@BillWagner BillWagner self-assigned this May 7, 2024
@BillWagner BillWagner added 🗺️ reQUEST Triggers an issue to be imported into Quest. doc-bug Problem with the content; needs to be fixed [org][type][category] and removed by-design labels May 7, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 7, 2024
@dotnet-policy-service dotnet-policy-service bot added the okr-health Content-health KR: Concerns article defects/freshness or build warnings. label May 7, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc lang-reference/subsvc okr-health Content-health KR: Concerns article defects/freshness or build warnings. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants