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

Can we have multiple constructors in a class c#?

0 Answers  


why do we use Overloading, Overriding, Boxing, Unboxing, and what is the use of these ?

3 Answers   eXensys,


Which .gang of four. Design pattern is shown below?

0 Answers  


How many types of variables are there in c#?

0 Answers  


How do you serialize in c#?

0 Answers  


Why do we need private constructor in c#?

0 Answers  


What is stringwriter c#?

0 Answers  


What is event delegate in c#?

0 Answers  


Why do we need delegates?

0 Answers  


What does private void mean in c#?

0 Answers  


may we achieve polyphormsm through overloading a funtion?Is it right or wrong concept because i read polyphormism can be achieved through overloading?plz help me thnks

1 Answers  


What is called method in c#?

0 Answers  


Categories