public WorkContext(string type) { switch (type) { case "A": algorithm = new AlgorithmA(); break; case "B": algorithm = new AlgorithmB(); break; case "C": algorithm = new AlgorithmC(); break; default: break; } }