【发布时间】:2023-04-01 11:21:02
【问题描述】:
我可以使用以下代码在 C# 中轻松定义具有某些对象类型的新集合:
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
// in some other method
var listPesrons = new List<Person>
{
new Person { Id = 0, Name = "Oleg" },
new Person { Id = 1, Name = "Lena" }
};
上面代码列表的 Swift 编程语言的类比是什么?
【问题讨论】:
标签: list generics swift collections initialization