using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; namespace WindowsFormsApplication8 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Paster<Ent>(String dicNo) where Ent : class, new() { var ent = new Ent(); var list = new List<Ent>(); for (int i = 0; i < 10; i++) { var e = new Ent(); list.Add(e); } Console.WriteLine(typeof(Ent).ToString() + "__" + dicNo +"___" + ent); } private void button1_Click(object sender, EventArgs e) { Type t = this.GetType(); BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance; var m1 = this.GetType().GetMethod("Paster", flags); var info= m1.MakeGenericMethod(typeof(SEnt)); //object list = t.InvokeMember(null, // BindingFlags.DeclaredOnly | // BindingFlags.Public | BindingFlags.NonPublic | // BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { }); info.Invoke(this,new Object[]{"ttt"}); } } public class SEnt { public String Name { get; set; } public override string ToString() { return DateTime.Now.ToString(); } } }