KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an interface interface IInterface<E>{ E Foo(); } I then create a class like this class Bar : IInterface<String>, IInterface<Int32> { } This actually works out quite well, except I need to define one of the two functions with the interface explicit, like this: class Bar : IInterface<String>, IInterface<Int32> { String Foo(); Int32 IInterface<Int32>.Foo(); } The drawback is that I have to do a cast every time I want to reach the Foo() which has the explicit interface. What are the best practices when dealing with this? I'm doing a very performance dependent application, so I really don't want to do a million casts per second. Is this something the JIT will figure out, or should I store a casted version of the instance in itself? I have not tried this specific code, but it looks awfully close to what I am doing.
Tags (comma-separated)
Save Edits
Cancel