泛型摘录
来源:互联网 发布:个人怎么查同盾数据 编辑:程序博客网 时间:2024/05/11 16:23
一段类型转化
--------------------------------------------------------------------
///
/// Gets the value.
///
///
/// Name of the column.
///
public T GetValue
{
columnName = columnName.ToLowerInvariant();
object oVal;
try
{
oVal = this[columnName].CurrentValue;
}
catch
{
throw new ArgumentException("There's no column called '" + columnName + "' for this object", "columnName");
}
if(oVal == null || oVal == DBNull.Value)
return default(T);
Type type = typeof(T);
if(type == typeof(object))
return (T)oVal;
// handle nullable type conversion
if(IsNullable(type))
{
NullableConverter converter = new NullableConverter(type);
type = converter.UnderlyingType;
}
//if (IsNullable(type) || type == typeof(object))
//{
// if (type == typeof(bool?))
// return (T)(object)Convert.ToBoolean(oVal);
// return (T)oVal;
//}
//if (type == typeof(Guid))
// return (T)(object)new Guid(oVal.ToString());
Type valType = oVal.GetType();
if(valType == typeof(Byte[]))
return (T)Convert.ChangeType(oVal, valType);
return (T)Convert.ChangeType(oVal, type);
}
- 泛型摘录
- 摘录
- 摘录
- >摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 摘录
- 关于Left join 到 Inner join 的提升--MSSQL自动转换
- gridview跟ObjectDatasource的一些说明与
- gridview 编辑状态下的列表框(DropDownList)使用注意
- 魔兽世界电子令牌数据库设计的一些推测
- Asp.net中的Button.Enabled=false VS Button.Visible=false
- 泛型摘录
- 关于asp.net中partial,asp.net编译笔记
- 通过gridview.DataSouce=ds绑定数据时GridViewDeleteEventArgs e 的key为空
- Asp.net用户控件(UserControl)的一些设计说明
- Windows2003,IIS6.0下的Asp.net的一些配置说明
- SubSonic中RecordBase.Load(IDataReader dataReader)与LoadAndCloseReader(IDataReader dataReader)的使用区别
- jquery操作下拉框(select)的一些说明
- 地址重写中使用httpModule映射.htm的问题
- WebSen!NT的行业分类说明