fork download
  1. using static System.Console;
  2. using Kitty.Core.Blocks;
  3.  
  4. public class Program {
  5. public static void Main() {
  6. var bloco1 = new Block<string>("título", "conteúdo");
  7. var bloco2 = new Block<string>("título2", "conteúdo2");
  8. WriteLine(bloco1.Equals(bloco2));
  9. WriteLine(bloco1.Equals(bloco1));
  10. }
  11. }
  12.  
  13. namespace Kitty.Core.Blocks {
  14. class Block<T> {
  15. public string Title { get; private set; }
  16. public T Contents { get; private set; }
  17.  
  18. public Block(string title, T contents) {
  19. this.Title = title;
  20. this.Contents = contents;
  21. }
  22.  
  23. public override bool Equals(object obj) {
  24. Block<T> other = obj as Block<T>;
  25. if (other == null) return false;
  26. return Title == other.Title;
  27. }
  28. }
  29. }
  30.  
  31. //https://pt.stackoverflow.com/q/123930/101
Success #stdin #stdout 0.02s 15836KB
stdin
Standard input is empty
stdout
False
True