Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6112515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:45:14+00:00 2026-05-23T14:45:14+00:00

I have a C# method that returns very large number of objects. This is

  • 0

I have a C# method that returns very large number of objects. This is to be consumed in Matlab.

namespace MyNameSpace{
    public static class MyClass{
        public static IEnumerable<MyDataObject> GetVeryLargeResponse(){
            while(CheckForSomeFunkyConditionThatsRarelyTrue()){
               yield return GetMyNextDataObject();
            }
            yield break;
        }
    }
}

In Matlab when I make a call

result = MyClass.GetVeryLargeResponse();

I would expect result to be of type IEnumerable<MyDataObject>, so as to be able to get the Enumerator<MyDataObject> by calling result.GetEnumerator().

Where as I’m getting result which is of type MyNameSpace.<GetVeryLargeResponse>d_3 with no GetEnumerator() method available. I do see one of result‘s Super class being System.Collections.Generic.IEnumerable<MyClass>.

Is there a way I can iterate over this in Matlab or even to ‘cast’ result to IEnumerable<MyClass> in Matlab.

p.s.

  1. Converting to Array / IList etc is not feasible due to data volume
  2. This is not duplicate of How can I iterate over a C# IEnumerable in Matlab?, as that is dealing with IQueryable specifically.
  3. I’m using Matlab 2010b
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:45:15+00:00Added an answer on May 23, 2026 at 2:45 pm

    The result does have a GetEnumerator() method – it’s just may be implemented with explicit interface implementation.

    If Matlab isn’t willing to handle that, you could always write your own mapping type and an extension method to make things simpler:

    public static class Extensions
    {
        public static EnumerableWrapper<T> Wrap<T>(this IEnumerable<T> source)
        {
            return new EnumerableWrapper<T>(source);
        }
    }
    
    public class EnumerableWrapper<T> : IEnumerable<T>
    {
        private readonly IEnumerable<T> source;
    
        public EnumerableWrapper(IEnumerable<T> source)
        {
            this.source = source;
        }
    
        public IEnumerator<T> GetEnumerator()
        {
            return new EnumeratorWrapper<T>(source.GetEnumerator());
        }
    
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
    
    public class EnumeratorWrapper<T> : IEnumerator<T>
    {
        private readonly IEnumerator<T> source;
    
        public EnumeratorWrapper(IEnumerator<T> source)
        {
            this.source = source;
        }
    
        public T Current { get { return source.Current; } }
    
        object IEnumerator.Current { get { return Current; } }
    
        public bool MoveNext()
        {
            return source.MoveNext();
        }
    
        public void Reset()
        {
            source.Reset();
        }
    
        public void Dispose()
        {
            source.Dispose();
        }
    
    }
    

    Then try:

    result = MyClass.GetVeryLargeResponse().Wrap();
    

    It seems very odd for Matlab not so support this out of the box though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that basically returns the results of a mysql query. public
I have class method that returns a list of employees that I can iterate
I have a method that returns a list of type string. I want to
I have a method that returns lot of data, should I use @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) for
I have a method that returns an IEnumerable<KeyValuePair<string, ArrayList>> , but some of the
Scenario I have a method that returns a list of processes using WMI. If
I have a site in multiple languages. I have a method that returns me
I have a controller method that returns a jSON object and in one calling
I have a method (C++) that returns a character and takes an array of
Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.