经典的代码: using System; class CommaDelimitedFile ... { public CommaDelimitedFile(string fileName) ...{ Console.WriteLine("[CommaDelimitedFile."+"CommaDelimitedFile]file name={0}",filename); } } enum TableId ... { Customers, Suppliers, Vendors} ; class DbTable:CommaDelimitedFile static string GetFileName(TableId tableId) ... { string fileName; switch(tableId) ...{ case TableId.Customers: fileName="customers.txt"; break; case TableId.Supplied; fileName="suppliers.txt"; break; case TableId.Vendors: fileName="venders.txt"; break; default: throw new ArgumentException("[DbTable."+ "GetFileName] Could not resolve table name"]; } return fileName; } public DbTable(TableId tableId): base (GetFileName(tableId)) ... { Console.WriteLine("[DbTable.DbTable]tableId={0}","+tableId.ToString()); } } class BaseInitializer4 ... { public static void Main() ...{ Cosole.WriteLine("[Main] Instantiating a " + "Customer Table object..."); DbTable derived=new Dbtable(TableId.Customers); } }