Initializing collections that contain nested collections

前端 未结 3 1935
被撕碎了的回忆
被撕碎了的回忆 2021-01-27 18:13

How do I initialize a collection of \'Quote\' objects based on the class shown below where \'Quote\' would contain a collection of at least 5 \'Rate\' objects.

          


        
3条回答
  •  误落风尘
    2021-01-27 18:36

    List quotes = new List {
      new Quote { 
        Id = 1,
        Rates = new List {
          new Rate {
            Id = 1,
            AccommodationType = "Whatever",
            Price = 0m
          },
          new Rate { ......
          }
        }
      }
    };
    

提交回复
热议问题