int i=1;
long longOne=i; //assignment works fine
//...but
bool canAssign=(typeof(long).IsAssignableFrom(typeof(int))); //false
Why is canAssign false?
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.
When you assign an
intto along, all that happens is implicit conversion.longOneis an actuallong(as if you initialized it to be1L), and not anintmasquerading as along, if you get the drift.That is,
int(orInt32) andlong(orInt64) aren’t related in terms of inheritance or implementation; they just happen to be convertible because both are integral number types.