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 indexer c#?
What is exe file in c#?
What is scope c#?
What is list collection in c#?
What is yield in c#?
If casting fails what type of exception is thrown?
Between windows authentication and sql server authentication, which one is trusted and which one is untrusted?
Can you access a hidden base class method in the derived class?
Explain the OOPS concept in C#?
Explain the access modifiers in c#?
What are access modifiers used for?
What is difference between ienumerable and list in c#?
What is null character in string?
Differentiate between sqlclient oledb and providers?
Explain about CTS?