as will never throw a InvalidCastException. Instead, it returns null if the cast fails (which would give you a NullReferenceException if obj in your example were not a string).
as will never throw a InvalidCastException. Instead, it returns null if the cast fails (which would give you a NullReferenceException if obj in your example were not a string).