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 does out mean in c#?
Can I define a type that is an alias of another type (like typedef in c++)?
What is the difference between function and method in c#?
What does it mean?
Explain how do you convert a value-type to a reference-type?
Which language is used for desktop application?
What is singleordefault?
What are the basics of c#?
What is the full form of GAC? Explain its uses?
What is datatable in c#?
Why delegates are type safe?
What are floating point numbers?
What is sqlconnection in c#?
Why is c# a good programming language?
Why do we use overloading in c#?