0
点赞
收藏
分享

微信扫一扫

CollectionTest

using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Collections.ObjectModel;namespace CollectionTest
 {
     class Program
     {
         static void Main(string[] args)
         {
             Collection<User> coluser = new Collection<User>();
             User tom = new User("Tom");
             User jim = new User("Jim");
             User lucy = new User("Lucy");
             coluser.Add(tom); coluser.Add(tom); coluser.Add(tom);
             coluser.Add(jim);
             coluser.Add(lucy);
             foreach (User u in coluser)
             {
                 Console.WriteLine(u);
             }
         }
     }
 }
 /*
 Tom
 Tom
 Tom
 Jim
 Lucy
 请按任意键继续. . .
  */
using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;namespace CollectionTest
 {
     class User
     {
         String name;
         public User(String _name)
         {
             name = _name;
         }
         public override String ToString()
         {
             return name;
         }
     }
 }

举报
0 条评论