interface IBar { void Hidden(); }
class Foo : IBar { public void Visible() { /*...*/ } void IBar.Hidden() { /*...*/ } }
class Program
{
static T CallHidden1<T>(T foo) where T : Foo
{
foo.Visible();
((IBar)foo).Hidden(); //Cast required
return foo;
}
static T CallHidden2<T>(T foo) where T : Foo, IBar
{
foo.Visible();
foo.Hidden(); //OK
return foo;
}
}
¿Hay alguna diferencia (CallHidden1 vs. CallHidden2) es el código compilado real? ¿Existen otras diferencias entre dónde T: Foo y dónde T: Foo, IBar (si Foo implementa IBar) que en el acceso a los miembros de la interfaz implementados explícitamente?Interfaz explícitamente implementada y restricción genérica