您可以通过将操作传递给方法来完成此操作.就像是
private void actOnData(Client client, string[] pks, ActionaddThing) { foreach (string pk in pks) { string data = JObject.Parse(DBUtils.GetData(Constants.DBProcedures.GetProcedures.GetWorkerDetailsByPkid, pk))[Constants.ResponseJson.Data].ToString(); addThing(client, data); } } private void initClerks(Client client) { string[] pks = client.ClerksPKS.Trim(',').Split(','); actOnData(client,pks,(c,d) => { c.addClerk(JsonConvert.DeserializeObject (d)[0]); }); } private void initManagers(Client client) { string[] pks = client.ManagerPK.Trim(',').Split(','); actOnData(client, pks, (c, d) => { c.addManager(JsonConvert.DeserializeObject (d)[0]); }); }