CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Collection of Members

    Hey everyone. First time poster, long-time lurker. I may have found a question unanswered by search. Or I just don't know how to ask it.

    Any easy way to pass a collection of class members? Other than making a new list?

    So:

    Code:
    class Foo
    {
    public int x;
    
    }
    
    void MyFunc(List<int> list)
    {
        doSomething(list);
    }
    
    Main
    {
    List<Foo> listFoo = new List<Foo>();
    
    List<int> listInt = new List<int>();
    
    foreach (Foo foo in listFoo)
        listInt.Add(foo.x);
    
    MyFunc(listInt);
    
    }
    There's got to be something easier, right?
    Last edited by ordonator; January 6th, 2010 at 02:43 AM. Reason: Added code tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured