反射的样例(临时代码备存,可以反射List和Dictionary<,>)
2017-02-26 15:47:43 访问(1352) 赞(0) 踩(0)
/// <summary>
/// 反射的样例
/// </summary>
public static void ReferenceList()
{
//Type type = obj1.GetType();
//IList list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type));
//list.Add(obj1);
//Type type1 = obj1.GetType();
//Type type2 = obj2.GetType();
//IDictionary dictionary = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>).MakeGenericType(type1, type2));
//dictionary[obj1] = obj2;
}
//public static object GetDemoList(object oThis,object keyValue)
//{
// Type thisType = oThis.GetType();
//}
//public static Dictionary<string, List<MyDemoClass>> CreateDemo()
//{
// Dictionary<string, List<MyDemoClass>> theResult = new Dictionary<string, List<MyDemoClass>>();
// List<MyDemoClass> theList = new List<MyDemoClass>();
// theResult.Add("one", theList);
// theList = new List<MyDemoClass>();
// theResult.Add("two", theList);
// return theResult;
//}
标签:
反射的样例(临时代码备存,可以反射List和Dictionary< 


>) 


上一条:
下一条:
相关评论
发表评论