public IPredefinedInterface
{
void DoSomething(Object obj);
}
public class MyClass<T> : IPredefinedInterface
{
public void DoSomething(Object obj)
{
if (!(obj is T)) throw new ???
SomeOtherFunc((T)obj);
}
}
Not sure what the appropriate exception here is… ArgumentException, InvalidCastException, etc?
It’s a problem with the argument, so
ArgumentException. You haven’t actually done the cast, soInvalidCastExceptionis not appropriate.