I've gotta be missing something simple here.
Take the following code:
public IEnumerable<int> getInt(){
for(int i = 0; i < 10; i++){
yield return i;
}
}
I can call this with:
foreach (int j in obj.getInt()){
//do something with j
}
How can I use the getInt method without the foreach loop:
IEnumerable<int> iter = obj.getInt();
// do something with iter ??
Thanks.
EDITS
For those wondering why I'd want this. I'm iterating two things:
IEnumerator<int> iter = obj.getInt().GetEnumerator();
foreach(object x in xs){
if (x.someCondition) continue;
iter.MoveNext();
int n = iter.current();
x.someProp = n;
etc...
}