Skip to content

Revised out parameter modifier for C# 7 - #1605

Merged
rpetrusha merged 5 commits into
dotnet:masterfrom
rpetrusha:out-keyword
Mar 7, 2017
Merged

rpetrusha merged 5 commits into
dotnet:masterfrom
rpetrusha:out-keyword

Conversation

@rpetrusha

Copy link
Copy Markdown
Contributor

#Revised out parameter modifier for C# 7

Summary

Updated the topic to cover C# 7, and also did some cleanup (described in the Details section).

Fixes #1378

Details

In addition to documenting the declaration of the out variable in the method call, I've done the following:

  • Moved code from the codesnippets subdirectory to a subdirectory of samples/snippets.
  • Deleted code in the codesnippets subdirectory.
  • Removed most of the text for out.md, so that the topic only links to the two contextual out keywords. The out-parameter-modifier.md topic completely duplicated the out.md topic, which poses a maintenance nightmare and makes it certain that the identical topics (which also had examples in independent code files) will eventually get out of sync.
  • Modified the toc (toc.md) so that out.md is not in the TOC. It serves to disambiguate out, but does not otherwise appear in the TOC.

Suggested Reviewers

@BillWagner

@rpetrusha rpetrusha self-assigned this Feb 28, 2017
@rpetrusha rpetrusha added this to the 2017-Quarter 1 milestone Feb 28, 2017

@BillWagner BillWagner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rpetrusha I like the changes and the reorganization.

I left a couple suggestions for possible changes. I'm fine merging this either way. :shipit:


## Example

## Declaring an `out` method

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not really an out method. It's a method with out arguments. Maybe

Declaring out arguments

is a better heading?


[!code-cs[csrefKeywordsMethodParams#4](../../../../samples/snippets/csharp/language-reference/keywords/out/out-4.cs)]

A common pattern involves returning a `bool` to indicate whether an operation succeeded and failed, and returning the value produced by the operation in an `out` argument. A number of parsing methods, such as the @System.DateTime.TryParse(System.String,@System.DateTime) method, use this pattern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're trying to standardize on calling this the "Try* Pattern". It'd be great to use that term here.

@rpetrusha

Copy link
Copy Markdown
Contributor Author

Thanks, @BillWagner. I've incorporated both of your suggestions. I'll merge as soon as the topic builds.

@rpetrusha
rpetrusha merged commit f383c77 into dotnet:master Mar 7, 2017
@rpetrusha
rpetrusha deleted the out-keyword branch March 7, 2017 16:46
@mairaw mairaw removed this from the 2017-Quarter 1 milestone Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# Language reference keywords: out

4 participants