请问一个泛型转换的问题
本帖最后由 wggfcusmq 于 2013-11-22 11:46:20 编辑
private static T GetParametersValue<T>(string paraname, object defaultvalue)
{
if (HttpContext.Current.Session == null)
{
DataTable dt_para = new SDERP.BLL.SysManage.Sys_Parameters().GetList("PID='" + paraname + "'");
if (dt_para.Rows.Count != 0)
HttpContext.Current.Session = dt_para.Rows;
else
HttpContext.Current.Session = defaultvalue;
}
if (typeof(T) == typeof(bool))
{
return (T)((object)(Convert.ToInt32(HttpContext.Current.Session.ToString()) == 1));
}
else
return (T)HttpContext.Current.Session[paraname];
}