日期:2014-05-17 浏览次数:21004 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class MyClass
{
public static Dictionary<int, string> SexList = new Dictionary<int, string>();
public string this[int i]
{
get { if (SexList.ContainsKey(i)) return SexList[i]; else return "男"; }
}
}
class Program
{
static void Main(string[] args)
{
MyClass.SexList.Add(1, "男");
MyClass.SexList.Add(2, "女");
MyClass instance = new MyClass();
for (int i = 0; i <= 5; i++)
{
Console.WriteLine(instance[i]);
}
}
}
}