CollectionTest

来源:互联网 发布:淘宝旺旺号 编辑:程序博客网 时间:2024/06/02 13:58

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 0