Performance Differences

A lot of times value types store data directly, whereas reference types store only the address of the data. Although you can create and consume types according to your needs, there are some concerns with performance, particularly regarding methods. Methods can accept parameters, also known as arguments. Arguments can be value types or reference types. If you pass a value type to a method, you pass to that method all the data contained in the value type, which could be time-consuming and cause performance overhead. Passing a reference type passes only the address to the data, so it could be faster and more efficient. There could be situations in which you need to pass one or more value types to methods. What you pass depends on your needs. Generally, the performance difference in such a scenario is not relevant, but it depends on the size of the value type. If your method receives a large value type as an argument but is invoked only once, performance should not be affected. But if your method is invoked many times, perhaps passing a reference type would be better. Just be aware of this when implementing your methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.66.156