Difference between direct type casting and using "as" keyword?
Answer Posted / 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 View All Answers
What is an xsd file?
what are nullable types in c#
What is lazy in c#?
What do you mean by streamreader/streamwriter class in c#?
What is the and operator in c#?
Which is faster abstract class or interface in c#?
What is regex c#?
What is iqueryable in linq?
why delegate is type safe?
What are the types of operator?
What is linq c#?
Which is the best language for desktop application?
What is entity framework c#?
What is a nullreferenceexception and how do I fix it?
What is threading in c# with example?