写代码有两年多的时间了,越来越觉得代码的通用性是衡量一个程序员的标准。
代码
#region SqlDataReader => List
/// <summary>
/// author:Stone_W
/// date:2010.11.29
/// desc:SqlDataReader 转 List
/// </summary>
/// <param name="dr">SqlDataReader</param>
/// <returns>List</returns>
private static List<object> sqlDrToList(SqlDataReader dr)
{
List<object> list = null;
if (null != dr)
{
list = new List<object>();
object obj;
try
{
while (dr.Read())
{
... // 业务
}
}
catch (Exception ex) { }
finally
{
if (null != dr && dr.IsClosed == false)
{
dr.Close();
}
}
}
return list;
}
#endregion