Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 0.72 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public abstract class Player
  2. {
  3.     //fields
  4.     private Sport _sport;
  5.  
  6.     //properties
  7.     protected Sport Sport
  8.     {
  9.         get { return _sport; }
  10.         set { _sport = value; }
  11.     }      
  12. }
  13.        
  14. Player player = new FootballPlayer();
  15. Sport sport = player.Sport;
  16.        
  17. protected Sport Sport { get; set; }
  18.        
  19. public Sport Sport { get; protected set; }
  20.        
  21. protected Sport Sport
  22.        
  23. public Sport Sport
  24.        
  25. public abstract class Player
  26. {
  27.     // Changed to auto property to save some key strokes...
  28.     protected Sport Sport { get; set;}
  29. }
  30.  
  31. public RealPlayer : Player
  32. {
  33.     public void Foo(Sport sport)
  34.     {
  35.         this.Sport = sport; // Valid
  36.     }
  37. }
  38.        
  39. var realPlayer = new RealPlayer();
  40. realPlayer.Sport // Compilation error.
clone this paste RAW Paste Data