What is the best way to return two lists in C#?

前端 未结 5 2381
情话喂你
情话喂你 2020-12-31 05:12

I am almost embarrassed to ask this question, but as a long time C programmer I feel that perhaps I am not aware of the best way to do this in C#.

I have a member fu

5条回答
  •  悲哀的现实
    2020-12-31 05:47

    Your first suggestion isn't two lists. It's a list of lists.

    The second option would do what you intend, but you might want to change it to use the out keyword instead of ref so the callers of your method will know the intention of what you're doing.

    public void ReturnTwoLists(out List listOne, out List listTwo);
    

提交回复
热议问题