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
Give an example to show for hiding base class methods?
Why ienumerable is used in c#?
What is datareader c#?
What is the use of console?
How to Install uninstall assemblies into GAC?
Can you see a loop recorder?
What is difference between internal and protected internal in c#?
How many types of constructors are there in c#?
What is boolean conditions in c#?
Which is faster abstract class or interface in c#?
Can constructor be overloaded in c#?
i want the csharp questions&answeres
Is goto statement supported in c#?
Explain copy constructor?
What is firstordefault c#?