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 happens if you inherit multiple interfaces and they have conflicting method names?
What is uint16?
How to do and Apply Themes to Datagrid,Lable,Textbox,etc., in C#.NET 2005 Windows Application? (like who we will do themes in ASP.NET using .CSS and .SKIN files). Urgent!!
Can interface inherit class in c#?
How to use the sreamReader class to read form a text file?
What is selector c#?
What does static mean in c sharp?
What is the syntax for calling an overloaded constructor within a constructor?
What is private in c#?
What is the use of table aliases?
What's c# ?
What is the output of TextWriterTraceListener redirected?
How does return work in c#?
Do unused Namespaces in c# affect run-time performance?
What sort algorithm does c# use?