>>105923600Thought it'd be cool but it's actually kinda meh.
Writing the templates wasn't fun.
I guess F# is more appropriate for something like this.
class Program
{
static void Main()
{
int n = 5;
n.Inc().Mul(6).ConvertTo<double...>().Sum(10, 20, 5, 10.5).Div(5).Print();
}
static int Inc(this int a)
{
return a + 1;
}
static T Mul<T>(this T a, T b) where T : operator T * T
{
return a * b;
}
static T ConvertTo<T, TFrom>(this TFrom a) where T : operator explicit TFrom
{
return (T)a;
}
static T Div<T>(this T a, T b) where T : operator T / T
{
return a / b;
}
static T Sum<T>(this T a, params T[] nums) where T : operator T + T
{
T sum = a;
for (let n in nums)
{
sum += n;
}
return sum;
}
static void Print<T>(this T a)
{
Console.WriteLine("{}", a);
}
}