Good afternoon, very much I float in a subject about the generalized interfaces, methods. I would be very grateful for the hint, or for the links in which direction to dig, read. I read the theory from the website professorweb.ru about interfaces, generalization. The theory by the theory that I understood something, which is not, but in practice I still cannot implement the next task.
For example, there is a code:
DataPerson dataPerson; IEnumerable<Person> person = dataPerson.<IEnumerable<Person>>Get(); // как я понял, метод Get() должен в person записать значение ссылочного типа // на реализующий интерфейс типа Person? Не представляю как реализовать это. // В плане непонятны мне следующие вопросы: // 1. Где следует реализовать этот интерфейс? // 2. Не понимаю про двойное обобщение вида <T<V>>, // а именно каким образом это указать в методе Get()? // 3. Не понимаю как вернуть интерфейс через метод. Person class:
class Person { public string FirstName { get; set; } public string LastName { get; set; } public Person(string fName, string lName) { FirstName = fName; LastName = lName; } } DataPerson class:
class DataPerson { // как я примерно представляю объявление функции Get() public IEnumerable Get<T,V>() where T : IEnumerable<V> { // как реализовать, к сожалению не представляю } } How to actually implement the Get () method in the DataPerson class?