Possible Duplicate:
Casting: (NewType) vs. Object as NewType
Casting vs using the 'as' keyword in the CLR
//var gridView = (gridViewRow.NamingContainer as GridView); <-- works too
var gridView = (GridView)gridViewRow.NamingContainer;
My incomplete understanding of this is using as
keyword can give null
when using a cast ()
will throw an exception. My goal is to be able to ask myself "which way should I cast?" and know how to answer it.