正在加载图片...
List<T>添加斤麦 必须是T类型:其 中T是特定类型 int Add(T value)∥添加一个对象到集合的末尾 返回索引 void Insert(int index,T item); ∥添加一个T对象到集合index索引处 1∥遍历 List<Student>myset new List<Student>(); I∥myset.Add(3);∥编译错误:无法从int转换为Student Student s1 new Student(); s1.sno =101;s1.sname "Lisa"; myset.Insert(0,s1); myset.Add(s1); 18 18 List<T>添加元素 int Add(T value) //添加一个对象到集合的末尾 返回索引 可为null 必须是T类型:其 中T是特定类型 void Insert(int index, T item); //添加一个T对象到集合index索引处 //遍历 List<Student> myset = new List<Student> ( ); // myset.Add(3); // 编译错误:无法从int转换为Student Student s1 = new Student( ); s1.sno = 101; s1.sname = "Lisa"; myset.Insert(0, s1); myset.Add(s1);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有