Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Test
- {
- class Person
- {
- protected string someField;
- public Person(string field)
- {
- this.SomeField = field;
- }
- public virtual string SomeField
- {
- get => someField;
- set => someField = value + " from Person";
- }
- }
- class Employee : Person
- {
- public Employee(string field) : base(field)
- {
- this.SomeField = field;
- // base.SomeField = field;
- }
- public override string SomeField
- {
- get => someField;
- set => someField = value + " from Employee";
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Person a = new Employee("Pesho");
- Console.WriteLine(a.SomeField);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement