代码改变世界

C# GetType()

2017-09-29 15:17  FingalZhu  阅读(286)  评论(0编辑  收藏  举报

T model = new T();

PropertyInfo[] propertys = model.GetType().GetProperties();

foreach (PropertyInfo pi in propertys)

                {

if (type == typeof(object))//T是dymamic

                {

                    type = datasource.FirstOrDefault().GetType();

                }