Skip to content

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"

@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
@BillWagner BillWagner requested a review from tdykstra November 21, 2024 20:08
@BillWagner BillWagner requested a review from adegeo December 2, 2024 14:54
@BillWagner
Copy link
Member Author

ping @adegeo for review

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 force-pushed the parameter-passing-modes branch from 0bb98eb to 2adfc7a Compare December 3, 2024 13:57
Copy link
Member

@IEvangelist IEvangelist left a comment

Choose a reason for hiding this comment

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

Looks good to me, :shipit: when you're ready.

@BillWagner BillWagner enabled auto-merge (squash) December 5, 2024 14:20
@BillWagner BillWagner merged commit b424baa into dotnet:main Dec 5, 2024
8 checks passed
@BillWagner BillWagner deleted the parameter-passing-modes branch December 5, 2024 14:24
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-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

None yet

2 participants