整列リスト---SortedList
=====================メインプログラム
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<string, string> s = new SortedList<string, string>();
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();
}
}
}