mi piacerebbe essere in grado di fare qualcosa del genere:Perché non è possibile utilizzare un tipo concreto compatibile in sede di attuazione di un'interfaccia
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
public interface IFoo
{
IEnumerable<int> integers { get; set; }
}
public class Bar : IFoo
{
public List<int> integers { get; set; }
}
}
Perché il compilatore si lamenta ..?
Error 2 'Test.Bar' does not implement interface member 'Test.IFoo.integers'. 'Test.Bar.integers' cannot implement 'Test.IFoo.integers' because it does not have the matching return type of 'System.Collections.Generic.IEnumerable<int>'.
Capisco che l'interfaccia IEnumerable dice e la classe utilizza un elenco, ma una lista è un IEnumerable .....
cosa posso fare? Non voglio specificare IEnumerable nella classe, voglio usare un tipo concreto che implementa IEnumerable, come Elenco ...
"Voglio utilizzare un tipo di cemento che implementa IEnumerable , come Elenco ... "- perché? – jcollum