Possible Duplicate:
Direct casting vs 'as' operator?
Firstly I am sorry if this is a duplicate, I have tried to google but it is not an easy “google to do”!
Is there a difference (functionally, performance wise, etc) between the following code fragments:
MyClass myClass = (MyClass)someObject;
MyClass myClass = someObject as MyClass;
Yes there is a difference!
as operator will set variable to null if casting fails
Explicit casting will raise exception