return single instance object as IEnumerable

后端 未结 4 1696
夕颜
夕颜 2021-01-01 17:10

I have in instance of class foo and i want to return it as IEnumerable. Can i do it without creating a new list etc..

Perhaps something like the following:



        
4条回答
  •  攒了一身酷
    2021-01-01 17:26

    you could do this:

    public IEnumerable GetSingleFooAsEnumerable() { 
        yield return singleFoo;
    }
    

提交回复
热议问题