Using IEnumerable without foreach loop

后端 未结 7 1046

I\'ve gotta be missing something simple here.

Take the following code:

public IEnumerable getInt(){
  for(int i = 0; i < 10; i++){
   y         


        
7条回答
  •  醉酒成梦
    2020-11-30 03:44

    How about this?

    IEnumerator iter = obj.getInt();
    using(iter) {
        while(iter.MoveNext()) {
            DoSomethingWith(iter.Current)
        }
    }
    

提交回复
热议问题