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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.