Returning two lists in C#

后端 未结 6 1481
清歌不尽
清歌不尽 2020-12-06 19:06

I have been researching this for a while now, and am still unsure on how to implement and what is the best way to return two lists from a separate method?

I know the

6条回答
  •  半阙折子戏
    2020-12-06 19:18

    A better practice IMO would be passing two lists to your desired method and initializing / assigning them from within the method itself. Example:

    public static void Method2(int[] arr, List list1, List list2)
    {
        list1 = arr.OfType().ToList();
        list2 = arr.OfType().ToList();
    }
    

提交回复
热议问题