using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace listAndnew
{
public class objectmouse
{
public string Name { get; set; }
public bool Sex { get; set; }
public int Age { get; set; }
}
class Program
{
static List<objectmouse> list = new List<objectmouse>();
static List<List<objectmouse>> list1 = new List<List<objectmouse>>();
static Random seed = new Random();
static void Main(string[] args)
{
int a = 0;
while (a < 2)
{
int flag = 0;
objectmouse mouse = new objectmouse();
list.Clear();///////////使用clear()方法输出图1
//list = new List<objectmouse>();/////////////使用new输出图2
while (flag < 2)
{
mouse.Name = "小白鼠";
mouse.Age = seed.Next(20);
mouse.Sex = true;
list.Add(mouse);
flag++;
}
list1.Add(list);
a++;
}
for (int i = 0; i < list1.Count; i++)
{
for (int j = 0; j < list.Count; j++)
{
Console.WriteLine("Name" + list1[i][j].Name + "Sex:" + list1[i][j].Sex + "Age:" + list1[i][j].Age);
}
Console.WriteLine("----------------华丽的分割线-------------------");
}
Console.ReadKey();
}
}
}