.net - Why can't I tell that `I is I`? -


I found this setup in my code:

  Public Intangible Class ModelBase {} Public Interface Imodelbase & lt; T & gt; {} Public abstract class ModelBase & lt; T & gt; : Modelbase, Imodelbase and Lieutenant; T & gt; {} Public Class Mayclass: Modelbase & Lieutenant; Int & gt; {}   

and then later I will be able to call FutureValue & lt; by NHibernate. MyClass & gt; The object is given, and I try:

  if (ozage is the iFutureValue ) // = & gt; false? // or if (ozza future value ) // = & gt; false?   

In the meantime, if I type it directly:

  if I want to make it public from other uses to make Future Value public to the source of NHibernate ) ((IFutureValue & lt; MyClass & gt;) obj) Value is ModelBase) // = & gt; truth! // or if (((Future Value   

... seriously? This is in the legacy series, is there no reason to see it? Observing the object in the debugger shows that it is actually a mylalus, and it has ModelBase methods and properties, so I suspect that there is nothing to do with NHibernate's proxying.

Why the .NET is such a legacy chain? What are some keywords / casting moves I can do to do this? Or, I have to resort to a big, clunky setup:

  if (oz iFuTureLEY.MicLAS>) returns ((eFureThereMyClass & gt; OBG) value; If (oz's IFutureValue & lt; MyOtherClass & gt;) return ((IFutureValue & lt; MyOtherClass & gt;) obj); value; // etc end   

Edit: NET 2.0 has


edit2: (I) the exact code of the Future value:

  Public Interface IFutureValue  {T Value {Received ;}} Public Class Future Value & lt; T & gt;: IFutureValue & Lt; T & gt; Public Representative IList & lt; T & gt; GetResult (); Private Readonly GetResult getResult; Public Future Value {getResult = Result;} Public T Value {get {var results = getResult (); If (result number == 0) {return default (t);} return result [0];}}}   

Do I misunderstand the sympathetic / corrupted issue (In this case, why funk gtc: f1 = MyMethod; can be inserted Func & lt; Type3, Type1 & gt; F2 = f1; (Where is the type of return type first), but the above code can not do the same? Until it's just. NET 2.0 is not even lame with polymofism?


edit3: Think while typing. Is this the case because IList & lt; T & gt; Defines delegates who take, say, derivative type, therefore derivative or dualized t is required, but can the withdrawal type be only t or base? So I can not put any direction ... I wonder if I should call NHibernate to IEnumerable & lt; T & gt; Can I refuse to switch in my future in ... Will she solve it?

IFutureValue & lt; T & gt; is a common interface with a Covariant type-parameter. You are expecting the behavior of a Contravariant gene Rick type parameter

Comments