//以字符串为下标的索引器
public class IDXer2
{
private Hashtable name = new Hashtable();
public class IDXer2
{
private Hashtable name = new Hashtable();
//以字符串为下标的索引器
public string this[string index]
{
get
{
return name[index].ToString();
}
set
{
name.Add(index, value);
}
}
}
public string this[string index]
{
get
{
return name[index].ToString();
}
set
{
name.Add(index, value);
}
}
}
public class Program
{
static void Main(string[] args)
{
//以字符串为下标的索引器
IDXer2 indexer2 = new IDXer2();
indexer2["A01"] = "张三";
indexer2["A02"] = "李四";
Console.WriteLine(indexer2["A01"]);
Console.WriteLine(indexer2["A02"]);
Console.ReadKey();
} }
{
static void Main(string[] args)
{
//以字符串为下标的索引器
IDXer2 indexer2 = new IDXer2();
indexer2["A01"] = "张三";
indexer2["A02"] = "李四";
Console.WriteLine(indexer2["A01"]);
Console.WriteLine(indexer2["A02"]);
Console.ReadKey();
} }
//以字符串为下标的索引器
public class IDXer2
{
private Hashtable name = new Hashtable();
public class IDXer2
{
private Hashtable name = new Hashtable();
//以字符串为下标的索引器
public string this[string index]
{
get
{
return name[index].ToString();
}
set
{
name.Add(index, value);
}
}
}
public string this[string index]
{
get
{
return name[index].ToString();
}
set
{
name.Add(index, value);
}
}
}
public class Program
{
static void Main(string[] args)
{
//以字符串为下标的索引器
IDXer2 indexer2 = new IDXer2();
indexer2["A01"] = "张三";
indexer2["A02"] = "李四";
Console.WriteLine(indexer2["A01"]);
Console.WriteLine(indexer2["A02"]);
Console.ReadKey();
} }
{
static void Main(string[] args)
{
//以字符串为下标的索引器
IDXer2 indexer2 = new IDXer2();
indexer2["A01"] = "张三";
indexer2["A02"] = "李四";
Console.WriteLine(indexer2["A01"]);
Console.WriteLine(indexer2["A02"]);
Console.ReadKey();
} }
https://www.cnblogs.com/lxblog/p/3940261.html