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
Define using statement in c#?
What is dao in c#?
What is bitwise operator in c#?
Write a sample code to write the contents to text file in c#?
What is expression tree in c#?
Which compiler switch creates an xml file from xml comments in the files in an assembly?
What is difference between tostring() vs convert.tostring() vs (string) cast
What is the and operator in c#?
What is the xml document structure?
what is boxing and unboxing?can we initialize unboxing directly?
What is parse method in c#?
What is a verbatim string literal and why do we use it?
Is list immutable in c#?
what is the difference between convert.tostring() and tostring() functions ?
What is xpath in c#?