CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public interface IPessoa<T> where T : IPessoa<T>
{
string Nome { get; set; }
IList<T> Get();
}
public class Pessoa<T> : IPessoa<Pessoa<T>> where T : Pessoa<T>
{
public string Nome { get; set; }
public virtual IList<Pessoa<T>> Get()
{
return new List<Pessoa<T>>();
}
}
public class Aluno : Pessoa<Aluno>
{
public override IList<Pessoa<Aluno>> Get()
{
return new List<Pessoa<Aluno>>();
}
}
public static void Main(string[] args)
{
var aluno = new Aluno();
IList<Pessoa<Aluno>> alunos = aluno.Get();
alunos.Add(new Aluno { Nome = "Vítor"});
alunos.Add(new Aluno { Nome = "Bruno" });
foreach (Pessoa<Aluno> a in alunos)
Console.WriteLine(a.Nome);
Console.ReadLine();
}
}