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
Is c and c# the same?
Write a program to find the angle between the hours and minutes in a clock
What does string format do?
How do you specify a custom attribute for the entire assembly (rather than for a class)?
What does == mean in c sharp?
What is strongly typed in c#?
What does static mean in c sharp?
Why do we need singleton class in c#?
Can a dictionary have duplicate keys c#?
What does typeof return c#?
How can you set image source dynamically from c# application to ”test.png” file?
Difference between value and reference type. What are value types and reference types?
What is difference between internal and protected internal in c#?
How does it work?
What is a di class?