4 ms·
> How does the runtime know if you can “Deconstruct” an object? It implicit based on whether the object implements the appropriate method? Based on what I hav
by SideburnsOfDoom 9y ago
> How does the runtime know if you can “Deconstruct” an object? It implicit based on whether the object implements the appropriate method?
Based on what I have read below, it's implicit; there's very little that the runtime has to know - it happens at compile time, with the compiler looking for a method with the name "Deconstruct" and the right type signature, and plugging that in during the compile.
The compiler already does a lot of heavy lifting codegen for language features like async / await
https://andrewlock.net/deconstructors-for-non-tuple-types-in-c-7-0/ https://andrewlock.net/deconstructors-for-non-tuple-types-in...
http://www.techcartnow.com/new-c-sharp-7-features-in-action-deconstruction-in-c-sharp-7/ http://www.techcartnow.com/new-c-sharp-7-features-in-action-...