.net - How does the compiler choose the target overload with two interface methods sharing the same signature except one is generic? -


system.collections.generic.list(of t) implements system.collections.ienumerable , system.collections.generic.ienumerable(of t), each have getenumerator() method (respectively):

function getenumerator() system.collections.ienumerator function getenumerator() system.collections.generic.ienumerator(of t) 

assume have mylist instance of system.collections.generic.list(of t); if call mylist.getenumerator(), compiler targets function getenumerator() system.collections.generic.ienumerator(of t) , function getenumerator() system.collections.ienumerator hidden intellisense list. indeed, if @ system.collections.generic.list(of t) using ilspy, latter overload missing.

i want create own collection class implements 2 interfaces, have this:

class myitemcollection     implements system.collections.ienumerable,          system.collections.generic.ienumerable(of item)      private _items new system.collections.generic.list(of item)      public function getenumerator() ienumerator(of item) _         implements ienumerable(of item).getenumerator          return _items.getenumerator()     end function      public function getenumerator1() ienumerator _         implements ienumerable.getenumerator          return _items.getenumerator()     end function end class 

notice have use getenumerator , getenumerator1 because, due return type difference, can't combine them 1 getenumerator method. if leave out function getenumerator() system.collections.ienumerator compiler error.

how system.collections.generic.list(of t) away not implementing both overloads if that's, in fact, it's doing, or if not, how determine overload it's going present? how can achieve result vb.net code?

note: think, the_lotus pointed out, has explicit interface implementation, doesn't exist in vb.net in c#.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -