using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyIndex
{
class Program
{
static void Main(string[] args)
{
Person per = new Person();
Console.WriteLine(per[2]);
Console.ReadKey(true);
}
}
public class Person
{
public string[] Names = { "asd", "ddd", "asda" };
//索引器//
public string this[int index]
{
get
{
string txt = "";
switch(index)
{
case 0:
txt = Names[0];
break;
case 1:
txt = Names[1];
break;
case 2:
txt = Names[2];
break;
}
return txt;
}
}
}
}
索引
最新推荐文章于 2024-06-04 11:26:25 发布