Difference between direct type casting and using "as" keyword?



Difference between direct type casting and using "as" keyword?..

Answer / amitabh dubey

Explicit cast throws an InvalidCastException if the object
can not be casted. you have to
Keep the casting under try / catch block to handle the
exception.
Instead you can use as operator which return null if it
can not cast the object.

Is This Answer Correct ?    25 Yes 0 No

Post New Answer

More C Sharp Interview Questions

difference between managed code and unmanaged code ?

3 Answers  


What is delegates in c# and uses of delegates?

0 Answers  


What is the purpose of a console table?

0 Answers  


Which is the base class in c#?

0 Answers  


Is string nullable in c#?

0 Answers  






What is literal control

0 Answers  


About delegates and events?

2 Answers   ADITI,


How many variables do you need?

0 Answers  


What are jagged arrays used for?

0 Answers  


What is the importance of closing an ado.net application?

0 Answers  


1) how to delete duplicate records from table in sql server 2005 2) what is run time polymorphism

4 Answers   HCL, IBM, L&T,


Difference between value and reference type.

0 Answers  


Categories