CSharp · Console
using System;
using System.Numerics;
public class Program
{
public static TResult Test<TResult>() where TResult : INumber<TResult>
{
TResult x = TResult.AdditiveIdentity;
TResult y = TResult.MultiplicativeIdentity;
TResult z = x * y;
TResult z2 = z * TResult.CreateChecked(2);
return z2;
}
public static void Main()
{
Console.WriteLine(Test<decimal>());
}
}