Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.67/5 (5 votes)
See more:
in c#. are primitives such as int (which behind-the-scenes are structs i.e. System.Int32) therefore objects? since primitives are pass by value, it contradicts the fact that objects are pass by reference? please anyone enlighten me. thanks.

Posted

1 solution

swjam wrote:
it contradicts the fact that objects are pass by reference?


Well, actually everything is passed by value (unless you specify otherwise). When you pass an object you are actually passing the reference to the object, and as the reference is a value type it's passed by value, i.e. the value of the reference is copied.

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900