I have often wondered what exactly does casting do at compiler or machine level. What does it do with the 0 and 1s in memory?
Can anyone point me at some good literature.
Casting doesn't modify the individual bits when casting between reference types, it just instructs the compiler/runtime to interpret the bits in a specific way if possible.
If the cast is not possible at compile time due to incompatible types an error is issued. If the cast is not possible at runtime an exception is thrown.
The wiki page on type conversion has additional information.
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