我想通过反射获取一个类的type,Version,Culture,PublicKeyToken。请问该怎么做?

解决方案 »

  1.   

            /// <summary>
            /// 返回IList数据集
            /// </summary>
            /// <param name="startIndex">开始页数</param>
            /// <param name="endIndex">结束页数</param>
            /// <returns>实体类集合</returns>
            public IList<T> GetData(int startIndex, int endIndex)
            {
                this.startIndex = startIndex;
                this.endIndex = endIndex;
                SqlParameter[] parameters = SetParameter(false);            IList<T> list = new List<T>();
                Type type = typeof(T);
                PropertyInfo[] properties = type.GetProperties();
                using (SqlDataReader sdr = SqlHelper.ExecuteReader(SqlHelper.connectionString, CommandType.StoredProcedure, "KFS_Pagination", parameters))
                {
                    while (sdr.Read())
                    {
                        T t = Activator.CreateInstance<T>();
                        for (int i = 0; i < properties.Length; i++)
                        {
                            properties[i].SetValue(t, sdr[i + 1], null);                    }                    list.Add(t);
                    }
                }
                return list;
            }
      

  2.   

    不是类的信息,是这个类所在程序集的信息
    typeOf(string).Assembly.FullName
      

  3.   

    int i = 42;
    System.Type type = i.GetType();
    System.Console.WriteLine(type);System.Reflection.Assembly o = System.Reflection.Assembly.Load("A.dll");
    System.Console.WriteLine(o.GetName());
      

  4.   


                Type t = typeof(int);
                Console.WriteLine(t.FullName);
                Console.WriteLine(t.Assembly.FullName);