Hi I just want to know for knowledge why there are Value Types in C# or Java . Why they all are not Reference Types?. I can see two reasons for my own: 1)Performance: All commonly used DataTypes are Value types since Value Types have single round where as Reference Types have two rounds first to stack and then to heap.So performance can be the reason. 2)Assigning Values.Any help will be highly appericiated.Thanks
Part of it is performance but a bigger reason is the resulting behavior. You tend to think of integers (for example) as immutable value types. However, if you're dealing with an object, you would be surprised if updating a field in that object wasn't maintained in a calling method because you were modifying a copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With