zoukankan      html  css  js  c++  java
  • C# 系列,这里是C#高级编程里面的,里面用了个索引符,没有明白到是啥意思哦。今天太晚了不想弄了。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Collections;

    namespace ConsoleApplication1
    {
        public class Studuent : IEnumerable
        {
            private object[] temp = new object[100];
            private string name;
            private int number;
            public Studuent()
            {
                this.name = null;
                this.number = 0;
            }
            public Studuent(string Name, int Number)
            {
                this.number = Number;
                this.name = Name;

            }

            public string this[uint i]
            {
                get
                {
                    return temp[i];
     
                }
                set
                {
                    temp[i] = value;
                }
            }

           

            #region IEnumerable 成员

            public IEnumerator GetEnumerator()
            {
                return new StudentEnumerator(this);
            }

            #endregion
        }

        public class StudentEnumerator : IEnumerator
        {
            Studuent theStudent;
            int location;

            public StudentEnumerator(Studuent thestudent)
            {
                this.theStudent = thestudent;
                location = -1;

            }

            #region IEnumerator 成员

            public object Current
            {
                get
                {
                    if (location < 0 || location > 2)
                        throw new InvalidOperationException("不在集合中");
                    return theStudent[(uint)location];

                }
            }

            public bool MoveNext()
            {
                ++location;
                return (location > 2) ? false : true;
            }

            public void Reset()
            {
                this.location = -1;
            }

            #endregion
        }
        class Program
        {
            static void Main(string[] args)
            {
                Studuent[] stu = new Studuent()[100];

            }
        }
    }

  • 相关阅读:
    poj3613 Cow Relays【好题】【最短路】【快速幂】【离散化】
    poj1734 Sightseeing trip【最小环】
    poj1094 Sorting It All Out【floyd】【传递闭包】【拓扑序】
    BZOJ2200 道路和航线【好题】【dfs】【最短路】【缩点】
    CH6101 最优贸易【最短路】
    poj3662 Telephone Lines【最短路】【二分】
    codeforces#514 Div2---1059ABCD
    进阶指南---基本算法【阅读笔记】
    hdu5954 Do not pour out【积分】【二分】【待补.....】
    mariadb yum安装
  • 原文地址:https://www.cnblogs.com/fat_li/p/1831412.html
Copyright © 2011-2022 走看看