示例
using System;
using System.Collections.Generic;
namespace Test3
{
class Program
{
static void Main(string[] args)
{
KeyValuePair<string, int> key = new KeyValuePair<string, int>("aaa", 123);
Console.WriteLine(key.ToString());
Dictionary<KeyValuePair<string, int>, string> dic = new Dictionary<KeyValuePair<string, int>, string>();
dic.Add(key, "567");
Console.WriteLine(dic[key]);
Console.Read();
}
}
}
运行测试
namespace System.Collections.Generic
{
public struct KeyValuePair<TKey, TValue>
{
public KeyValuePair(TKey key, TValue value);
public TKey Key { get; }
public TValue Value { get; }
public override string ToString();
}
}