using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace 练习
{
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(N);
t.Start();
}
public static void N()
{
List<Student> list = new List<Student>();
list.Add(new Student("老孙"));
list.Add(new Student("老zhu"));
for (int i = 0; i < list.Count; i++)
{
list[i].name = "李四";
//Console.WriteLine(list[i].name);
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace 练习
{
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(N);
t.Start();
}
public static void N()
{
List<Student> list = new List<Student>();
list.Add(new Student("老孙"));
list.Add(new Student("老zhu"));
for (int i = 0; i < list.Count; i++)
{
list[i].name = "李四";
//Console.WriteLine(list[i].name);
}
foreach (var item in list)//list 在这里是一种类型,所以要用item.name
{
Console.WriteLine(item.name);
}
}
}
public class Student
{
public string name;
public Student(string name)
{
this.name = name;
}
}
Console.WriteLine(item.name);
}
}
}
public class Student
{
public string name;
public Student(string name)
{
this.name = name;
}
}
}