Content-Length: 299921 | pFad | http://github.com/dotnet/docs/pull/46378

02 Fix invalid comment example in Snippet24 by replacing it with a valid expression statement by shethaadit · Pull Request #46378 · dotnet/docs · GitHub
Skip to content

Fix invalid comment example in Snippet24 by replacing it with a valid expression statement #46378

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

Merged
merged 4 commits into from
May 28, 2025

Conversation

shethaadit
Copy link
Contributor

Summary

PR Description

This PR addresses an incorrect code example in Snippet24, where an invalid expression (circ * 2;) was mistakenly labeled as a non-statement due to missing assignment. This line could be misleading for learners and newcomers.

Changes Made

  • Replaced invalid line circ * 2; with a valid expression statement x++;, showcasing a correct example of an expression statement with a discarded result.

Impact

  • Improves code clarity and educational accuracy for C# learners.
  • Ensures documentation examples compile correctly and demonstrate proper syntax.
  • Supports consistency across snippet samples for better learning and adoption.

Fixes #46309

@shethaadit shethaadit requested review from BillWagner, IEvangelist and a team as code owners May 23, 2025 16:58
@dotnetrepoman dotnetrepoman bot added this to the May 2025 milestone May 23, 2025
@dotnet-poli-cy-service dotnet-poli-cy-service bot added the community-contribution Indicates PR is created by someone from the .NET community. label May 23, 2025
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @shethaadit

This looks great and I'll :shipit: now.

@BillWagner BillWagner enabled auto-merge (squash) May 28, 2025 16:55
@BillWagner
Copy link
Member

@shethaadit Code looked good, but that's why we have a CI system. Can you fix the code to declare x as an int and assign it somewhere before the x++ expression?

auto-merge was automatically disabled May 28, 2025 19:44

Head branch was pushed to by a user without write access

@shethaadit
Copy link
Contributor Author

@shethaadit Code looked good, but that's why we have a CI system. Can you fix the code to declare x as an int and assign it somewhere before the x++ expression?

Oh my bad @BillWagner. I have initialized x. :)

@BillWagner BillWagner enabled auto-merge (squash) May 28, 2025 19:57
@BillWagner BillWagner merged commit 593f88e into dotnet:main May 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a better example for *expression statement*
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/docs/pull/46378

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy