c# - How to properly return T from a generic method while implimenting an interface? -


I am working through a bug that I was able to determine in the rebuilding bug for the following sample Why the problem is happening but if I'm stuck for a better solution then the following program is given:

  Public interface IFoo & lt; T & gt; {T output type (Tom); } Square Fu: IFoo & lt; Foo & gt; {Public Virtual Foo Output Type (Foo Parm) {Console. Weidline ("Foo"); Return supreme; }} Category Bar: Foo, IFu & lt; Bars & gt; {Public Virtual Bar Output Type (Bar Ultimate) {Console.WriteLine ("Bar"); Return supreme; }} Class program {static zero main (string [] args) {time = new bar (); CallOutputType (bar); Bar.OutputType (bar); } Fixed zero call output type & lt; T & gt; (Tt) where t: fu {t. Output type (t); }}  

I expected to be output:

  repeatedly  

But what I'm getting:

  foo bar  

Simplifying this kind of problem It is clear that bar.optput type is not being overridden Foo.OutputType . What are my best options for improving this design? Bar.Optput Type can not override Foo.OutputType because signatures are different. Changing the signature of the bar.optput type to match Foo.OutputType will not work because then Bar IFoo .

Uh, I am not very familiar with this stuff, but it should not be:

  Fixed zero call output type  

This works when I compile it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -