Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Player
- {
- //fields
- private Sport _sport;
- //properties
- protected Sport Sport
- {
- get { return _sport; }
- set { _sport = value; }
- }
- }
- Player player = new FootballPlayer();
- Sport sport = player.Sport;
- protected Sport Sport { get; set; }
- public Sport Sport { get; protected set; }
- protected Sport Sport
- public Sport Sport
- public abstract class Player
- {
- // Changed to auto property to save some key strokes...
- protected Sport Sport { get; set;}
- }
- public RealPlayer : Player
- {
- public void Foo(Sport sport)
- {
- this.Sport = sport; // Valid
- }
- }
- var realPlayer = new RealPlayer();
- realPlayer.Sport // Compilation error.
Add Comment
Please, Sign In to add comment