在C#中获取SortedList对象的指定索引处的值
为了获得在SortedList对象的指定索引处的值,代码如下-
示例
using System;
using System.Collections;
public class Demo {
public static void Main(String[] args) {
SortedList list = new SortedList();
list.Add("A", "Jacob");
list.Add("B", "Sam");
list.Add("C", "Tom");
list.Add("D", "John");
list.Add("E", "Tim");
list.Add("F", "Mark");
list.Add("G", "Gary");
Console.WriteLine("索引 2 = "+list.GetByIndex(2));
Console.WriteLine("索引 5 = "+list.GetByIndex(5));
Console.WriteLine("索引 6 = "+list.GetByIndex(6));
}
}输出结果
这将产生以下输出-
索引 2 = Tom 索引 5 = Mark 索引 6 = Gary
示例
让我们看另一个例子-
using System;
using System.Collections;
public class Demo {
public static void Main(String[] args) {
SortedList list = new SortedList();
list.Add(1, "One");
list.Add(2, "Two");
list.Add(3, "Three");
list.Add(4, "Four");
list.Add(5, "Five");
Console.WriteLine("索引 0 = "+list.GetByIndex(0));
}
}输出结果
这将产生以下输出-
索引 0 = One
热门推荐
10 送给客人简短的祝福语
11 爸爸寿宴仪式祝福语简短
12 朝鲜元旦祝福语大全简短
13 毕业祝福语老婆生日简短
14 新婚贺词祝福语创意简短
15 给妈妈祝福语简短内容
16 过年红包祝福语简短霸气
17 新年酒会祝福语简短创意
18 离职送别文案祝福语简短