Casts the given obj to T or returns default if the cast fails.
The cast object or default.
The object to cast.
The class to cast to.
The default value to return if the cast fails.
The type to return.