Why is there a need to convert a value (for example short) to string, and then to Int32.
Why can it not be converted from short to Int 32?
Why is there a need to convert a value (for example short) to string,
Share
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.
There is no need to even to any sort of explicit conversion:
Also, any numeric literals (without any sort of suffix) are int32s anyway.
— Edit
The reason an explicit cast isn’t required is because a
shortis always smaller than anint, thus ashortwill always completely fit into the size of anint, so no potential loss of data.