using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 数组里存类
{
class Program
{
static void Main(string[] args)
{
List<Person> people = new List<Person>()
{
new Person(){Id = 01,Name = "张三"},
new Person(){Id =02,Name = "李四"}
};
Person[] person = new Person[2]
{
new Person(){Name = "lisa",Id=03},
new Person(){Name="john",Id=04}
};
Console.WriteLine(people[0].Id + people[0].Name);
Console.WriteLine(person[0].Name + person[0].Id);
Console.ReadKey();
}
class Person
{
public string Name { get; set; }
public int Id { get; set; }
}
}
}
c# 关于类的集合和数组的定义和初始化
最新推荐文章于 2023-03-14 21:53:57 发布