Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. IEnumerable<t></t>

IEnumerable<t></t>

Scheduled Pinned Locked Moved C#
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mehran asg
    wrote on last edited by
    #1

    hi. How can I return IEnumerable az a method parameter. In fact I want to return a table records. but I must return as IEnumerable; How can I fill IEnumerable and return it?

    S A L 3 Replies Last reply
    0
    • M mehran asg

      hi. How can I return IEnumerable az a method parameter. In fact I want to return a table records. but I must return as IEnumerable; How can I fill IEnumerable and return it?

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, you have to write a class that will implement the IEnumerable interface. Within the implementation you can move through your records. Have a look here: http://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28VS.80%29.aspx[^] By the way, if you are using the System.Data.Table then the Rows-Property offers a GetEnumerator() method which will return an enumerator for the records within the table. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      M 1 Reply Last reply
      0
      • S SeMartens

        Hi, you have to write a class that will implement the IEnumerable interface. Within the implementation you can move through your records. Have a look here: http://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28VS.80%29.aspx[^] By the way, if you are using the System.Data.Table then the Rows-Property offers a GetEnumerator() method which will return an enumerator for the records within the table. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        M Offline
        M Offline
        mehran asg
        wrote on last edited by
        #3

        a world of thanks. I 'll try to do it

        1 Reply Last reply
        0
        • M mehran asg

          hi. How can I return IEnumerable az a method parameter. In fact I want to return a table records. but I must return as IEnumerable; How can I fill IEnumerable and return it?

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Other than that, you can also use any class implemented from IEnumerable like Array, ArrayList, List etc... to return IEnumerable object. :)

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Microsoft Bing MAP using Javascript
          CLR objects in SQL Server 2005
          Uncommon C# Keywords
          /xml>

          1 Reply Last reply
          0
          • M mehran asg

            hi. How can I return IEnumerable az a method parameter. In fact I want to return a table records. but I must return as IEnumerable; How can I fill IEnumerable and return it?

            L Offline
            L Offline
            Lutoslaw
            wrote on last edited by
            #5

            Use a yield[^] keyword to return records as they go.

            IEnumerable<int> GetNumbers()
            {
            for (int i = 0; i < 100; i++)
            yield return i;
            }

            Now you can do:

            foreach (int number in GetNumbers())
            Console.WriteLine(number);

            Greetings - Jacek

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups