blob: d95386cffb2be508ad48a0aec0243c7af241604d (
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 gorilla.utility
{
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>();
}
}
}
|