summaryrefslogtreecommitdiff
path: root/lib/NumericConversions.cs
blob: 93f4be484c8783e4e077c81468431b902f553d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;

namespace jive
{
  public static class NumericConversions
  {
    public static int to_int<T>(this T item) where T : IConvertible
    {
      return Convert.ChangeType(item, typeof (int)).downcast_to<int>();
    }

    public static long to_long<T>(this T item) where T : IConvertible
    {
      return Convert.ChangeType(item, typeof (long)).downcast_to<long>();
    }

    public static double to_double<T>(this T item) where T : IConvertible
    {
      return Convert.ChangeType(item, typeof (double)).downcast_to<double>();
    }
  }
}