Skip to content

Added a very detailed example #7185

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

Closed
wants to merge 4 commits into from
Closed

Added a very detailed example #7185

wants to merge 4 commits into from

Conversation

PtrStruct
Copy link
Contributor

I decided to add a visual representation of the difference between reference types & value types.
Show just how they work on the stack as well as on the heap.

Summary

Describe your changes here.

Fixes #Issue_Number (if available)

I decided to add a visual representation of the difference between reference types & value types.
Show just how they work on the stack as well as on the heap.
@PtrStruct PtrStruct requested a review from BillWagner as a code owner August 22, 2018 10:30
@dnfclas
Copy link

dnfclas commented Aug 22, 2018

CLA assistant check
All CLA requirements met.

Fixed a minor spelling issue.
Fixed the last minor typos.
@pkulikov
Copy link
Contributor

@PtrStruct @BillWagner I have several concerns about this PR:

  • there should be (I don't know if such already exists) an article in the C# programming guide that explains difference between value and reference types. Then, that article can be linked from the C# reference topics (from both value type and reference type topics). The example from this PR would fit that article.
  • explanation should be moved out of comments to the text that explains the example. That makes localization possible.
  • at last, stack and heap (the implementation detail) can be omitted when describing the difference between value and reference types. Check related discussion in the following issue: Do not claim that structs are on the stack #4561 (especially this comment of @BillWagner)

@PtrStruct
Copy link
Contributor Author

@pkulikov I did look around the msdn and after doing so, I found this article to be the most fitting one.
There was one showing both types and minor differences, but that was for Visual Basic.
I am making some changes regarding your concern with the comments not being text.

Regarding @pkulikov regard I decided to edit the document splitting it up and explaining it a bit more.
I personally like this one a lot more.
Regarding his other concern about seeing this example else where becuase it would "fit" better there. I could unfortunately not find a better place for this example than right here
@BillWagner
Copy link
Member

@PtrStruct

Thank you for adding this. However, as @pkulikov mentioned, there are a number of concerns.

First, this example and the introduction in the article on classes and structs covers much of this information.

Second, as I stated in this comment value types are "on the stack" except when they aren't. They aren't on the stack when they are members of a reference type, in an array or other collection, captured by a closure, and so on. Your explanation is correct for the cases it covers, but it is misleading by not discussing those other cases.

I suggest we close this PR, you look at the classes and structs article referenced above. Then, if there is important information that you feel is lacking, submit a PR updating that topic.

What are your thoughts?

@PtrStruct
Copy link
Contributor Author

I understand, thanks.
You may close this PR.

@BillWagner
Copy link
Member

Thanks @PtrStruct

I'll close this.

@BillWagner BillWagner closed this Aug 22, 2018
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.

4 participants