62,074
社区成员
发帖
与我相关
我的任务
分享
public class MainClass
{
class Program
{
static void Main(string[] args)
{
List<Vo> list = new List<Vo>();
Vo vo1 = new Vo();
vo1.ID = 1;
vo1.name = "aa";
vo1.comm = "comaa";
list.Add(vo1);
Vo vo2 = new Vo();
vo2.ID = 2;
vo2.name = "bb";
vo2.comm = "combb";
list.Add(vo2);
//------------上面是添加------------
//方法一
foreach (Vo vo in list)
{
Console.WriteLine(vo.ID + "-" + vo.name + "-" + vo.comm);
}
//方法二
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine(list[i].ID + "-" + list[i].name + "-" + list[i].comm);
}
Console.ReadLine();
}
}
/// <summary>
/// 你的实体类
/// </summary>
public class Vo
{
public int ID { get; set; }
public string name { get; set; }
public string comm { get; set; }
}
}