c# - overloading explicit CAST operator with user-defined interface parameter -
c# - overloading explicit CAST operator with user-defined interface parameter - at these given classes [activerecord] public class basemoo : activerecordbase [activerecord] public class foo : basemoo { } somewhere in code do var fooobj = new foo(); // fooobj basemoo obj = fooobj; here seek cast var newfooobj = (foo)obj; // , goes if changes classes this: [activerecord(lazy=true)] public class basemoo : activerecordbase [activerecord(lazy=true)] public class foo : basemoo { } making lazyest @ these lines: var fooobj = new foo(); // fooobj basemoo obj = fooobj; the ar creates non foo instance instead basemooproxy object var newfooobj = (foo)obj; // throws invalidcast exception as sugested @adam houldsworth in this question i overloads foo explicit operator in way public static explicit operator foo(nhibernate.proxy.inhibernateproxy nhproxy) { var resultobj = (foo)nhproxy.insomewayigettheoriginalobject(); // insomewayigettheoriginalobje...