C# List 簡單範例

  • 361
  • 0

C# List 簡單範例

class Program
{
    static void Main(string[] args)
    {
        List<Address> addressList = new List<Address>();

        addressList.Add(new Address() { 
            Street = "Main Street",
            Zip = "1234"
        });
    }
}

public class Address
{
    public string Street { get; set; }

    public string Zip { get; set; }
}

資料來源:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/84f0b2a7-9f15-40f0-a6ed-8a4f84650c13/adding-object-to-list-and-adding-properties-at-same-time?forum=csharpgeneral