有序列表---SortedList<TKey,TValue>
==================================主程序

创新互联专业为企业提供绥滨网站建设、绥滨做网站、绥滨网站设计、绥滨网站制作等企业网站建设、网页设计与制作、绥滨企业网站模板建站服务,十年绥滨做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
//有序列表会按照键排序
SortedList s = new SortedList();
s.Add("a", "1");
s.Add("b", "3");
s["d"] = "2";
s["c"] = "4";
Console.WriteLine("--------------【遍历有序列表】-----------------");
foreach (var item in s)
{
Console.WriteLine(item.Key + "," + item.Value);
}
Console.WriteLine("--------------【遍历有序列表的值】-----------------");
foreach (var item in s.Values)
{
Console.WriteLine(item);
}
Console.WriteLine("--------------【遍历有序列表的键】-----------------");
foreach (var item in s.Keys)
{
Console.WriteLine(item);
}
//获取有序列表的值【安全获取】
string outstr;//返回值
string key = "a";//键
if (!s.TryGetValue(key,out outstr))
{
Console.WriteLine(key + "键不存在");
}
Console.WriteLine(outstr);
Console.ReadKey();
}
}
}
当前名称:有序列表---SortedList<TKey,TValue>
本文路径:http://www.jxjierui.cn/article/peseid.html


咨询
建站咨询
