.NET-like methods for safe casting.