I have an interface
interface IInterface<E>{ E Foo(); }
Then create a class like this
class Bar : IInterface<String>, IInterface<Int32> { }
This works really well, except that I need to define one of two functions with an explicit interface, for example:
class Bar : IInterface<String>, IInterface<Int32> { String Foo(); Int32 IInterface<Int32>.Foo(); }
The downside is that I have to do the cast every time I want to reach Foo (), which has an explicit interface.
What are the best ways to deal with this?
I am running a performance dependent application, so I really don't want to make a million throws per second. Is this something that the JIT will define, or should I store the cast version of the instance by itself?
I have not tried this specific code, but it is terribly close to what I am doing.
source share