Ilist<T>转换为List<T>
2013-03-29 17:03
344 查看
// **//// <summary>
/// 转换IList<T>为List<T>
/// </summary>
/// <typeparam name="T">指定的集合中泛型的类型</typeparam>
/// <param name="gbList">需要转换的IList</param>
/// <returns></returns>
public static List<T> ConvertIListToList<T>(IList<T> gbList) where T : class
{
if (gbList != null && gbList.Count >= 1)
{
List<T> list = new List<T>();
for (int i = 0; i < gbList.Count; i++)
{
T temp = gbList[i] as T;
if (temp != null)
list.Add(temp);
}
return list;
}
return null;
}
/// 转换IList<T>为List<T>
/// </summary>
/// <typeparam name="T">指定的集合中泛型的类型</typeparam>
/// <param name="gbList">需要转换的IList</param>
/// <returns></returns>
public static List<T> ConvertIListToList<T>(IList<T> gbList) where T : class
{
if (gbList != null && gbList.Count >= 1)
{
List<T> list = new List<T>();
for (int i = 0; i < gbList.Count; i++)
{
T temp = gbList[i] as T;
if (temp != null)
list.Add(temp);
}
return list;
}
return null;
}
相关文章推荐
- DataTable转换成List<T>
- c# List<实体>转换List<object>集合
- DataTable转换为List<Model>的通用类
- C# 中 Ilist<T> 转换成 DataTable
- 用string.Join与List<T>或者与string数组转换为字符串
- c#将List<T>转换成DataSet
- Hql的select 语句返回Ilist<object[]>类型,如何转换为映射类型
- 集合转换java:【List<-->数组、List<-->Set、数组<-->Set、Map-->Set、Map-->List】
- DataTable转换为List<Model>的通用方法
- 【.Net码农】List<T>转换为DataTable
- 通过反射把list<T>转换成datatable,kill进程,事务传入一个Lst<String>多条sql语句
- 【C#】List<T>类型强制转换
- .NET将字符串转换成List<T>
- 将DataTable或Ilist<>转换成JSON格式
- DataTable转换成List<T>
- NHibernate初探(二) 对于IList<object[]>到持久类类型的转换
- c#将List<T>转换成DataSet
- List<T>转换为DataTable
- java 将jso 格式的字符串转换为List<Map<String,String>>
- c# Json List<T> DataTable 数据相互转换