ordonator
January 5th, 2010, 02:25 AM
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:
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?
Any easy way to pass a collection of class members? Other than making a new list?
So:
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?