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

Fix copy-paste error method-parameters.md #42676

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andre1110
Copy link

@andre1110 andre1110 commented Sep 21, 2024

When you assign new instance to the value type paramenter by reference, the changes are visible from the caller method

var instance = new TestStruct { Property = 0 };
AssignNewInstance(ref instance);
Console.WriteLine(instance.Property);
// 42

void AssignNewInstance(ref TestStruct local)
{
    local = new TestStruct { Property = 42 };
    return;
}
struct TestStruct
{
    public int Property { get; set; }
}

Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/keywords/method-parameters.md docs/csharp/language-reference/keywords/method-parameters

@andre1110 andre1110 requested review from BillWagner and a team as code owners September 21, 2024 11:20
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates PR is created by someone from the .NET community. label Sep 21, 2024
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.

1 participant