zoukankan      html  css  js  c++  java
  • IEnumerator与IEnumerable探讨 (续)

    代码优先

        public class NewMyClass : IEnumerable, IEnumerator
    {
    private string[] Info;
    private int Index;
    public NewMyClass(int Size)
    {
    Index = -1;
    Info = new string[Size];
    for (int i = 0; i < Size; i++)
    {
    Info[i] = i.ToString();
    }
    }
    public object Current { get { return Info[Index]; } }
    public void Reset()
    {
    Index = -1;
    }
    public bool MoveNext()
    {
    Index++;
    return Index >= Info.Length ? false : true;
    }
    public IEnumerator GetEnumerator()
    {
    return (IEnumerator)this;
    }
    }

    以上是结合后的代码

  • 相关阅读:
    Bessie Goes Moo
    小P的强力值
    Max Flow
    约瑟夫
    Moocryption
    杂务
    排行榜
    银行贷款
    轰炸
    Contaminated Milk
  • 原文地址:https://www.cnblogs.com/shikyoh/p/2246462.html
Copyright © 2011-2022 走看看