Guest User

Untitled

a guest
Jan 4th, 2013
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  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.
Add Comment
Please, Sign In to add comment