ZIP不同大小的列表

时间:2015-12-07 10:03:47

标签: c#

列表2仅显示两个元素,但我需要4个元素

地址有4个元素

协会有2个元素

如果我要向关联添加两个元素,我会得到4个元素,如何自动完成。

            DT_createdRentalObject ro = new DT_createdRentalObject();

            //Add Address
            List<Address> la = new List<Address>();
            la.Add(new Address { City = "Arizona" });
            la.Add(new Address { City = "Texas" });
            la.Add(new Address { City = "California" });
            la.Add(new Address { City = "Florida" });
            ro.Address = la.ToArray();

            //Add Association
            List<Association> aso = new List<Association>();
            aso.Add(new Association { AssociationType = "1" });
            aso.Add(new Association { AssociationType = "2" });
            ro.Association = aso.ToArray();

            //Add LandData
            List<LandData> landa = new List<LandData>();
            landa.Add(new LandData { LandRegistrNumber = "12343" });
            landa.Add(new LandData { LandRegistrNumber = "8737" });
            landa.Add(new LandData { LandRegistrNumber = "2456" });
            ro.LandData = landa.ToArray();

            //Object
            List<MasterDataObjectID> mdobid = new List<MasterDataObjectID>();
            mdobid.Add(new MasterDataObjectID { IDType = "TYPID_212_12" });


            //ObjectType
            MasterData mdats = new MasterData();
            mdats.ObjectType = "Flat";
            mdats.ObjectID = mdobid.ToArray();
            ro.MasterData = mdats;

            var list =
                       ro.Address.Zip(ro.Association,
                       (add, asn) => new
                       {
                           ro.MasterData.ObjectID[0].IDType,
                           ro.MasterData.ObjectType,
                           add.City,
                           asn.AssociationType,
                       }
                      );

            var list2 = list.Zip(ro.LandData, (ld, lan) => new
                      {
                          ld.AssociationType,
                          ld.City,
                          ld.IDType,
                          ld.ObjectType,
                          lan.LandRegistrNumber
                      });

0 个答案:

没有答案