I was messing around to see what I could and could not do with regards to generics. I have this situation and as far as I'm concerned the compiler should throw an error with regards to ambiguous method calls but it compiles perfectly fine. Why is that?
public interface IFunctionStrategy<T>
{
T Strategy(params object[] parameters);
}
public class FunctionStrategyBase<T> : IFunctionStrategy<T>
{
public virtual T Strategy(params object[] parameters)
{
MethodBase current = MethodBase.GetCurrentMethod();
return (T)GetType().InvokeMember(current.Name, BindingFlags.InvokeMethod | BindingFlags.Public, Type.DefaultBinder, this, parameters);
}
}
public class ConnectionConnect : FunctionStrategyBase<int>
{
public int Strategy(int i)
{
return i;
}
}