Cartesian Product + N x M Dynamic Array

前端 未结 3 1859
心在旅途
心在旅途 2020-12-16 07:29

I have looked hours for a solution without any success. Hopefully someone can help me out.

I have a dynamic array of N items on M origin zip codes.

For insta

3条回答
  •  甜味超标
    2020-12-16 07:40

    You can use linq for that:

    var item1 = new[] { 11001, 54010, 60621 };
    var item2 = new[] {  11001, 60621 };
    var item3 = new [] { 60621 };
    IEnumerable cartesian = 
        from i1 in item1
        from i2 in item2
        from i3 in item3
        select new[] { i1, i2, i3 };
    

提交回复
热议问题