首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

paip.运用泛型时未能找到类型或命名空间名称“T

2012-09-07 
paip.使用泛型时未能找到类型或命名空间名称“Tpaip.使用泛型时未能找到类型或命名空间名称“T 使用泛型参数

paip.使用泛型时未能找到类型或命名空间名称“T

paip.使用泛型时未能找到类型或命名空间名称“T

 

使用泛型参数时,方法也需要加<T>标签...

 

 public void bindList2grid<T>(List<T> li, DataTable dt)
        {
            
            foreach (T tc in li)
            {
                  DataRow dr=     bindObj2Row(tc,dt);
                  dt.Rows.Add(dr);
            }
        
        }

 

 

 //反回值为范型
        public static T getValue<T>(object entity, string fieldName)
        {
            Type entityType = entity.GetType();
            PropertyInfo propertyInfo = entityType.GetProperty(fieldName);
            if (propertyInfo == null)
                return default(T);
            if (IsType(propertyInfo.PropertyType, "System.String"))
            {
                return (T)propertyInfo.GetValue(fieldName, null);

            }
            return default(T);
    
            //if (IsType(propertyInfo.PropertyType, "System.String"))
            //{
            //    propertyInfo.SetValue(entity, fieldValue, null);
        }

 

热点排行