zoukankan      html  css  js  c++  java
  • 实现ICollection

    using System;
    using System.Collections;//注意using Collections
    using System.Collections.Generic;
    using System.Text;

    namespace CollectionTest
    {
        
    class Program
        {
            
    static void Main(string[] args)
            {
                WordCollection words 
    = new WordCollection();
                
    foreach (string value in words)
                {
                    Console.WriteLine(value);
                }
                Console.Read();
            }
        }

        
    public class WordCollection : ICollection
        {
            
    private string[] _list;
            
    private object _root = new object();

            
    public WordCollection()
            {
                _list 
    = new string[] { "You""and""me""!" };
            }

            
    #region ICollection Members

            
    public void CopyTo(Array array, int index)
            {
                _list.CopyTo(array, index);
            }

            
    public int Count
            {
                
    get { return _list.Length; }
            }

            
    public bool IsSynchronized
            {
                
    get { return true; }
            }

            
    public object SyncRoot
            {
                
    get { return _root; }
            }

            
    #endregion

            
    #region IEnumerable Members

            
    public IEnumerator GetEnumerator()
            {
                
    return _list.GetEnumerator();
            }

            
    #endregion
        }
    }
  • 相关阅读:
    PY个树状数组
    PY 个板子计划【雾
    PY个欧拉筛
    【NOI2007】项链工厂 ——老题新做.jpg
    Min-Max 容斥的证明
    51nod 1963 树上Nim
    ●BZOJ 3566 [SHOI2014]概率充电器
    ●BZOJ 3640 JC的小苹果
    ●BZOJ 1444 [Jsoi2009]有趣的游戏
    ●Joyoi Dotp 驱逐猪猡
  • 原文地址:https://www.cnblogs.com/jazzka702/p/1503258.html
Copyright © 2011-2022 走看看