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 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is extension method in c# and how to use them?

686


Why do we need abstraction in c#?

677


Can we inherit partial class in c#?

683


How do you declare a variable in c#?

734


What is the implicit name and type of the parameter that gets passed into the class set method?

688


What is attribute and reflection in c#?

688


What is type checking in c#?

689


What is the difference between string keyword and system.string class?

742


What is use of console?

675


Is multiple inheritance possible in c#?

770


What is array collection?

706


What is different about switch statements in c#?

658


What is strong name in c# and how can we use it?

729


How does dictionary work in c#?

661


What are Indexers in C#?

771