How to initialize a list with constructor?

前端 未结 5 864
梦如初夏
梦如初夏 2021-01-31 16:14

I have a type:

public  class Human
{
    public int Id { get; set; }
    public string Address { get; set; }
    public string Name { get; set; }
    public List         


        
5条回答
  •  离开以前
    2021-01-31 17:11

    Are you looking for this?

    ContactNumbers = new List(){ new ContactNumber("555-5555"),
                                                new ContactNumber("555-1234"),
                                                new ContactNumber("555-5678") };
    

提交回复
热议问题