fork(1) download
  1. public class Program {
  2. public static void Main() {
  3. ITeste<Objeto> teste = new CarroTeste();
  4. }
  5. }
  6.  
  7. public class Objeto {
  8. protected string _nome;
  9. public string nome => _nome;
  10. }
  11.  
  12. public class Carro : Objeto {
  13. public Carro() => _nome = "Carro";
  14. }
  15.  
  16. public interface ITeste<out T> where T : Objeto {
  17. string GetNome();
  18. }
  19.  
  20. public abstract class TesteBase<T> : ITeste<T> where T : Objeto {
  21. protected Objeto _obj = null;
  22. public abstract string GetNome();
  23. }
  24.  
  25. public class CarroTeste : TesteBase<Carro> {
  26. public override string GetNome() => "Meu nome é : " + _obj.nome;
  27. }
  28.  
  29. //https://pt.stackoverflow.com/q/75097/101
Success #stdin #stdout 0.02s 13892KB
stdin
Standard input is empty
stdout
Standard output is empty