Possible Duplicate:
casting vs using the 'as' keyword in the CLR
I have seen two different ways of casting in C#.
For example:
MyObj foo = (MyObj) bar; // this is what I see most of the times
MyObj foo = bar as MyObj; // I do see this sometimes
- So, what is the basic difference?
- What are the proper names for the
style 1andstyle 2casting? - How do I decide when to use what?
- Is there any major performance issues?
- Is there anything else I should know of related to this topic?
Thanks a lot for looking into this :)