我有一个方法是这样的:
    public void Report(Form form, string[] textboxes, string[] patientdetails)
    {
        try
        {
            int i = 0;
            foreach (string textbox in textboxes)
            {
                form.Controls.OfType<TextBox>().FirstOrDefault(n => n.Name == textbox).Text = patientdetails[i];
                i++;
            }
            form.ShowDialog();
        }
        catch (Exception ex)
        {
        }
    }
通过将参数传递给这些未设置为实例对象的返回对象引用:
 string[] textboxes = new string[] { "txtPatientName", "txtAge", "txtGender","txtTestType","txtDate" }; 
 string[] patientDetails = new string[]{"Ammar Bashir", "19", "Male", "White Blood Cell Test", "12 March , 2013"};
 //Test a winform which contain textboxes.
  Report(Test, textboxes, patientDetails);