Skip to content

Instantly share code, notes, and snippets.

@temach
Created November 5, 2015 16:54
Show Gist options
  • Save temach/cc7c7afd65ed9abc881e to your computer and use it in GitHub Desktop.
Save temach/cc7c7afd65ed9abc881e to your computer and use it in GitHub Desktop.
Try that code
interface IPromotion {
void promote();
}
struct Employee : IPromotion {
public string Name;
public int JobGrade;
public void promote() {
JobGrade++;
}
public Employee(string name, int jobGrade) {
this.Name = name;
this.JobGrade = jobGrade;
}
public override string ToString() {
return string.Format("{0} ({1})", Name, JobGrade);
}
}
class Program
{
static void Main(string[] args)
{
Employee employee = new Employee("Cool Guy", 65);
IPromotion p = employee;
Console.WriteLine(employee);
Console.WriteLine(p);
p.promote();
Console.WriteLine(p);
Console.WriteLine(employee);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment