在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 祝福语驱散霉运的话简短