Skip to content

Conversation

@BillWagner
Copy link
Member

Fixes #5682

/cc @fitdev

Relies on dotnet/samples#133

@BillWagner BillWagner added the 🚧 Hold for related PR Indicates a PR can only be merged when other related PRs are merged (see comments for links) label Jun 21, 2018
@BillWagner BillWagner self-assigned this Jun 21, 2018
@BillWagner BillWagner requested a review from rpetrusha June 21, 2018 19:40
@BillWagner
Copy link
Member Author

closing and reopening to force a build.

@BillWagner BillWagner closed this Jun 21, 2018
@BillWagner BillWagner reopened this Jun 21, 2018
@BillWagner
Copy link
Member Author

yet another build.

@BillWagner BillWagner closed this Jun 21, 2018
@BillWagner BillWagner reopened this Jun 21, 2018
@BillWagner BillWagner removed the 🚧 Hold for related PR Indicates a PR can only be merged when other related PRs are merged (see comments for links) label Jun 26, 2018
Copy link
Contributor

@JRAlexander JRAlexander left a comment

Choose a reason for hiding this comment

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

Bill, looks good , except for a few small items.


[!code-csharp[readonly struct example](~/samples/snippets/csharp/keywords/ReadonlyKeywordExamples.cs#ReadonlyStruct)]

The preceding example uses readonly auto properties to declare its storage. That instructs the compiler to create `readonly` backing fields for those properties. You could also declare `readonly` fields directly:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a link to readonly auto properties?

public readonly int y = 5;
```

- For an instance field, in the instance constructors of the class that contains the field declaration, or for a static field, in the static constructor of the class that contains the field declaration. These are also the only contexts in which it is valid to pass a `readonly` field as an [out](out-parameter-modifier.md) or [ref](ref.md) parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

This first sentence is kind of awkward. I'm not sure what you are trying to say.


## Readonly struct example

The `readonly` modifier on a `struct` definition declares that the struct is **immutable**. Every instance field of the `struct` must be marked `readonly`, as shown in the following example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should immutable be surrounded by "`"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, that's not a keyword.

@BillWagner
Copy link
Member Author

Thanks @JRAlexander
Changes have been addressed.

@JRAlexander
Copy link
Contributor

LGTM. :shipit: when ready!

@BillWagner BillWagner merged commit 28c5745 into dotnet:master Jul 2, 2018
@BillWagner BillWagner deleted the update-readonly-keyword branch July 3, 2018 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants