コード例 #1
0
 /// <summary>
 /// Converts the object to the specified type or to the default value if it cannot
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="obj">The object.</param>
 /// <param name="formatProvider">The format provider.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentNullException"></exception>
 public static T ToOrDefault <T>(this IConvertible obj, IFormatProvider formatProvider)
 {
     return(obj.ToOrValue <T>(formatProvider, default(T)));
 }
コード例 #2
0
 /// <summary>
 /// Converts the object to the specified type or to the default value if it cannot
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="obj">The object.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentNullException"></exception>
 public static T ToOrDefault <T>(this IConvertible obj)
 {
     return(obj.ToOrValue <T>(default(T)));
 }