fork download
  1. public abstract class DayInfo
  2. {
  3. protected virtual void GetInfoCore() {
  4. throw new System.NotImplementedException();
  5. }
  6.  
  7. // or
  8. // protected abstract void GetInfoCore();
  9.  
  10. public void GetInfo() {
  11. GetInfoCore();
  12. }
  13. }
  14.  
  15. public class DayInfo<T> : DayInfo
  16. {
  17. private T info;
  18.  
  19. public DayInfo(T data) {
  20. info = data;
  21. }
  22.  
  23. public new T GetInfo() { // << This
  24. return info;
  25. }
  26.  
  27. protected override void GetInfoCore() {
  28. GetInfo();
  29. }
  30. }
  31.  
  32. static class Program
  33. {
  34. static void Main() {
  35. var item = new DayInfo<string>("aaa");
  36. var info = item.GetInfo();
  37. System.Console.WriteLine(info);
  38. }
  39. }
Success #stdin #stdout 0.02s 33888KB
stdin
Standard input is empty
stdout
aaa