[ExtensionMethods] System.IConvertible

Posted by Ahmed Tarek Hasan on 11/04/2012 08:10:00 PM with No comments
These are extension methods for "System.IConvertible" class. Some are written by me and the rest are collected from other sources. Hope you find them useful :)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace DevelopmentSimplyPut.ExtensionMethods.IConvertibleEM
{
 public static class IConvertibleExtensionMethods
 {
  public static T ext_ConvertTo<T>(this IConvertible value)
  {
   object holder = Convert.ChangeType(value, typeof(T));
   T result = default(T);
 
   if (null != holder)
   {
    result = (T)holder;
   }
 
   return result;
  }
 }
}