List of Records

前端 未结 3 1318
情书的邮戳
情书的邮戳 2021-01-29 07:06

The following code seems to add a new record to the list but overwrites all the record with the last record created. I can get it to work fine with ...

lpr.Add(n         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-29 07:33

    Is this what you are trying to achieve?

    private void button1_Click(object sender, EventArgs e)
    {
      List lpr = new List
      {
        new personRecord { Age = 40, Name = "Bob" },
        new personRecord { Age = 30, Name = "Steve"},
        new personRecord { Age = 44, Name = "Phil"},
        new personRecord { Age = 33, Name = "Sue"},
     };
    }
    

提交回复
热议问题