索引指示器

using System;
class Team
{
    string[] s_name = new string[8];
    public string this[int nIndex]
    {
        get {
            return s_name[nIndex];
        }
        set {
            s_name[nIndex] = value;
        }
    }
}

class Test
{
    public static void Main() {
        Team t = new Team();
        for(int i = 0; i < 6; i++)
        {
            Console.WriteLine(t[i]);
        }
    }
}

posted @ 2004-03-22 13:27  修多  阅读(394)  评论(0编辑  收藏  举报