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

What is platform independence"?

0 Answers   DELL,


What does the keyword virtual mean in the method definition?

2 Answers  


HOW to Develope the CRUD(create,read,update,delete) FORM IN WINDOWS form by using c# only

0 Answers   Petranics Solutions,


Why use a singleton instead of static methods?

0 Answers  


What is dll in c#?

0 Answers  






What is the boxing and unboxing in c#?

0 Answers  


explain synchronous and asynchronous in C#

3 Answers   AxSys, Mastek, Synechron,


How we free the memory in C#.NET.

3 Answers   Synechron,


How to assign default value to nullable types? Did nested nullable types are allowed

2 Answers   TCS,


What are the Types of compatabilities and explain them

0 Answers   DELL,


Explain the process of Serialization?

0 Answers  


WHICH IS THE BEST BOOK FOR A BEGINNER TO LEARN AP.NET 3.5, C#.NET & ALL THE FEATURES OF VISUAL STUDIO2008? WHAT ARE THE CERTIFICATIONS IN THIS FIELD? WHICH IS BEST BOOK FOR CLAERING CERTIFICATION EXAM? PLZ HELP ME YAAR

1 Answers  


Categories