The differences are:
- If a cast fails, it throws an
InvalidCastException. - If the
asoperator fails, it just returns a null reference. - You can’t use
aswith non-nullable value types (e.g. you can’t do “o as int“). - The cast operator is also used for unboxing. (
ascan be used to unbox to a nullable value type.) - The cast operator can also perform user-defined conversions.
EDIT: I’ve written elsewhere about when I feel it’s appropriate to use which operator. That might be worth a read…