Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COEverything after "Any time a struct is cast to an interface, it is boxed" is somewhat out-of-topic . . . but in the same time, it made me realize something important about generics, structs and interface, something a straight complete answer wouldn't have, namely, the difference between `bar<T>(IComparable<T> value)` and `bar<T>(T value) where T : IComparable<T>`, and so, why interfaces still matter a lot for structs, as long as we uses generics correctly. +1.
      singulars
    2. CO@paercebal: To my mind, what matters is not whether an answer precisely answers the exact question asked, but whether it provides information that will be useful to the original asker, and other people who click on the question. I figured that you would not only want to know whether a particular syntax would cause boxing, but also whether there would be an alternative way to write the code that would not. BTW, if I want to find out whether something will cause boxing, I write a simple program to create a WeakReference pointing to a new object (which is otherwise unused), then...
      singulars
    3. CO...I run the operation that might or might not require boxing a million times, and then see if the WeakReference is still valid. If the operation required any sort of heap allocation, a garbage-collection will occur and the WeakReference would be voided. If not, it won't. Note that there may be even better ways to detect garbage collection, but this way is pretty quick and easy to test.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload