directcast(123.34,integer) - should it throw an error? Why
or why not?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / debasis sengupta
directcast(123.34,integer) would throw an InvalidCast
exception as the runtime type since it requires the run-
time type of an object variable to be same as the specified
type. In this case runtime type of 123.34 (double) doesn?t
match with integer.
Is This Answer Correct ? | 1 Yes | 1 No |
Define Final Class in C#
What is the use of flag in c#?
What are interfaces in c#?
What is a collection class in c#?
What is a console?
What is exe in c#?
Is as keyword in c#?
Major difference between Basic httpbinding and WShttpbinding?
What is use of FormBoarderStyle Propertie
What's the difference between abstraction and encapsulation?
What are Uses of CLR
Which program construct must return a value?