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

Rework introduction on method parameters #43691

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

BillWagner
Copy link
Member

@BillWagner BillWagner commented Nov 21, 2024

Fixes #41087
Fixes #41628

The introductory discussion on value types, reference types, and pass by reference and pass by value only added to confusion.

So, in the method parameters article, simplify the discussion and remove all discussion of = ref. Add examples for each of the situations that is discussions.

Also, update the Assignment operator article to discuss the = ref implications of ref reassigning a parameter to a new object.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/keywords/method-parameters.md Method parameters and modifiers
docs/csharp/language-reference/operators/assignment-operator.md "Assignment operators - assign an expression to a variable"

Rework the examples and discussions on pass by value and pass by reference.  Remove the (more complicated) discussion of `= ref` and how that impacts modifying parameter values. That's coming in the next commit to the assignment article.
Point out that if you `ref =` assign a parameter to new storage, any subsequent value changes aren't visible outside the method.
@BillWagner BillWagner requested a review from a team as a code owner November 21, 2024 20:06
@dotnetrepoman dotnetrepoman bot added this to the November 2024 milestone Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot added okr-health okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-csharp/svc lang-reference/subsvc okr-health okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
1 participant