/// <summary> /// An object converter method which converts any type to another type. If value is null default value of type returns. In failure returns default value. /// </summary> /// <typeparam name="T">Targey type to convert.</typeparam> /// <param name="o">Object to be converted.</param> /// <param name="defaultValue">In any type of failure this method returns this value.</param> /// <param name="culture">Specific culture info for formatting.</param> /// <returns></returns> public static T Convert <T>(this object o, T defaultValue, string culture) { return(ConvertionHelper.GetConvertedValue <T>(o, defaultValue, culture)); }
/// <summary> /// An object converter method which converts any type to another type. If value is null default value of type returns. In failure throws exception. /// </summary> /// <typeparam name="T">Targey type to convert.</typeparam> /// <param name="o">Object to be converted.</param> /// <returns></returns> public static T Convert <T>(this object o) { return(ConvertionHelper.GetConvertedValue <T>(o)); }