Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Issue qualifying an generic interface

$
0
0

I created and generic interface and a class implements this interface twice.

public class MyClass: IMyInterface<Class1>, IMyInterface <Class2>
{
       List<Class1> IMyInterface<Class1>.MyMethod()
       {
           throw new NotImplementedException();
       }

       List<Class2> IMyInterface<Class2>.MyMethod()
       {
           throw new NotImplementedException();
       }
}

This works fine so far.

Now I am getting stuck when try to call one of the Methods. I tried:

MyClass myobject = new MyClass();
myobject.MyInterace<Class2>.MyMethod()

But this give a compiler error. Any idea?



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>