.net - Is it possible to override IEnumerable in VC++/CLI? -


i have interface returns ienumerable, , want implement in vc++/cli because data comes third-party unmanaged dll.

so far have:

public ref class myenumerable : ienumerable<sometype^> { public:     virtual ienumerator<sometype^>^ getenumerator(); } 

but compiler complains c2393: "covariant returns types not supported in managed types".

does mean cannot implement ienumerables in c++, or there workaround?

yikes, awfully clumsy error message. really complaining missing implementation of non-generic system::collections::ienumerable::getenumerator() method. must implement because generic ienumerable<> interface inherits non-generic one. made sense when generics first added in .net 2.0, not today. we're kinda stuck .net 1.x legacy.

otherwise easy when activate secret decoder ring, make this:

public ref class myenumerable : ienumerable<sometype^> { public:     virtual ienumerator<sometype^>^ getenumerator(); private:     virtual system::collections::ienumerator^ getenumerator1x()                 = system::collections::ienumerable::getenumerator {         return getenumerator();     } }; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -