Improve in
parameter modifier example with meaningful struct-based demonstration
#47134
+33
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #25422
Problem
The current example for the
in
parameter modifier uses a simpleint
parameter, which doesn't effectively demonstrate the purpose and benefits of thein
modifier. As pointed out in the issue:in
keyword, the value would still be 44 (sinceint
is a value type)in
in the first placeSolution
Replaced the inadequate
int
example with a comprehensive struct-based demonstration that addresses all concerns:Before (Problematic):
After (Improved):
What the New Example Demonstrates
in
: Performance benefits when passing large structs (avoids copying)in
parameter and regular parameter methods side-by-sidein
parameters cannot be modifiedChanges Made
FirstInExample()
method inRefParameterModifier.cs
with meaningful struct-based exampleLargeStruct
definition with multiple fields to demonstrate performance benefitsin
modifierThe example now clearly shows why developers would choose to use the
in
modifier and provides a practical, educational demonstration of its benefits.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.