using System; using System.Runtime.CompilerServices; using Microsoft.CSharp.RuntimeBinder; // Requires a reference to Microsoft.CSharp public class ImplicitTest { public double Val { get; set; } public ImplicitTest(double Val) { this.Val = Val; } public static implicit operator int(ImplicitTest d) { return (int)d.Val; } } public class TestClass { public int Val { get; set; } public TestClass(int Val) { this.Val = Val; } } public class Test { static void Main(string[] args) { var call = CallSite>.Create( Binder.InvokeConstructor(CSharpBinderFlags.None, typeof(Test), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.IsStaticType | CSharpArgumentInfoFlags.UseCompileTimeType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })); TestClass tc = call.Target.Invoke(call, typeof(TestClass), new ImplicitTest(15.5)); Console.WriteLine(tc.Val); } }