泛型
/// 泛型类型转换
public static T Convert2T<T>(string str, T defualtValue)
{
if (!string.IsNullOrEmpty(str))
{
object obj = Convert.ChangeType(str, typeof(T));
if (obj != null)
return (T)obj;
}
return defualtValue;
}
public static object getDicValue(string paramName, Dictionary<String, Object> divValues)
{
if (divValues.ContainsKey(paramName))
return divValues[paramName];
return null;
}
public static T getDicValue<T>(string paramName, Dictionary<String, Object> divValues, T defaultValue)
{
object value = getDicValue(paramName, divValues);
if (value != null)
return Convert2T<T>(value.ToString(), defaultValue);
return defaultValue;
}