封装一个类型转换的方法
public static class ObjectExtension { public static T Convert<T>(this object target) { T result = default(T); if (target != null) { result = (T)System.Convert.ChangeType(target, typeof(T), CultureInfo.InvariantCulture); } return result; } }