答案 0 :(得分:0)
class Employee
{
static int _empCount = 0;
static int GetNextEmployeeId()
{
_empCount++;
return _empCount;
}
public int EmployeeId { get; private set; }
public Employee()
{
EmployeeId = GetNextEmployeeId();
}
}
答案 1 :(得分:0)
命名空间Project1 {
class Employee
{
static int lastId;
protected int id;
public Employee()
{
this.id = lastId + 1;
lastId = this.id;
}
}
class Manager : Employee
{
public Manager() : base() { }
}
class Accountant : Employee
{
public Accountant() : base() { }
}
}