C > PropertyInfoからの型チェック

           Type t = p.PropertyType;
           if (typeof(decimal) == t || typeof(decimal?) == t)
           {
               ret = decimal.Parse(v);
           }
           else if (typeof(int) == t || typeof(int?) == t)
           {
               ret = int.Parse(v);
           }
           else if (typeof(long) == t || typeof(long?) == t)
           {
               ret = long.Parse(v);
           }
           else if (typeof(DateTime) == t)
           {
                   ret = DateTime.Parse(v);
           }
           else if (typeof(bool) == t)
           {
           }
           else
           {
               ret = v;
           }
最終更新:2010年04月14日 14:21