ソースコード
using System;
using System.Collections.Generic;
public static class Program
{
private static void Main()
{
var table = new Dictionary<int, string>
{
{ 1 , "フシギダネ" },
{ 2 , "フシギソウ" },
{ 3 , "フシギバナ" },
{ 4 , "ヒトカゲ" },
{ 5 , "リザード" },
{ 6 , "リザードン" },
};
if ( table.ContainsKey( 1 ) )
{
Console.WriteLine( "キーに 1 は含まれています" );
}
if ( table.ContainsValue( "ヒトカゲ" ) )
{
Console.WriteLine( "値に ヒトカゲ は含まれています" );
}
var result1 = table[ 5 ];
Console.WriteLine( result1 );
var result2 = "";
table.TryGetValue( 6, out result2 );
Console.WriteLine( result2 );
}
}