directcast(123.34,integer) - should it throw an error? Why
or why not?
Answer Posted / debasis sengupta
directcast(123.34,integer) would throw an InvalidCast
exception since it requires the runtime type of the object
variable to be same as the specified type. In this case
runtime type of 123.34 (double) doesn?t match with integer.
but for ctype(123.34,integer) - it would work fine. As the
runtime type of 123.34 would be double, and Double can be
converted to Integer.
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is difference between static and constant variable?
List down the reason behind the usage of c# language.
What is the difference between a variable and a literal?
What is the difference between interface and abstract class in c#?
What is a clr host?
Why do we use static methods in c#?
Can we extend sealed class in c#?
What do you know about Translate Accelerator?
What are the properties of string?
What is ienumerator c#?
Why do we need generics in c#?
Explain About friend and Protected friend
What is scope c#?
How do I link two windows forms in c#?
What is the reason behind the invention of c#?