Monday, August 9, 2010

InvalidCastException Questions

1. Why does the InvalidCastException occur?
It's trying to set an integer to a value which is a string.

2. What happens if you enter a number within the integer range?
It casts the value correctly and doesn't crash.

3. What is the correct data type to store a string in?
A String

4. What is the correct data type to store a number in?
An Integer

5. Can you store a number in a string variable?
Yes.

No comments:

Post a Comment